简体   繁体   中英

SQL Query on finding highest within duplicates

I am trying to write a SQL Query. If a duplicate SNO+SG Combination is found, we need to pick up the one having the highest value. If no duplicate value is found for a SNO+SG Combination, we will take that as it is. The sample input and output is over here:

样品在这里

Do you just want aggregation:

select bg, sno, sg, max(value)
from t
group by bg, sno, sg;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM