Select multiple (non-aggregate function) columns with GROUP BY

后端 未结 4 1211
醉酒成梦
醉酒成梦 2020-12-14 09:59

I am trying to select the max value from one column, while grouping by another non-unique id column which has multiple duplicate values. The original database looks somethin

4条回答
  •  一整个雨季
    2020-12-14 10:44

    Try using a virtual table as follows:

    SELECT vt.*,c.name FROM(
    SELECT c.mukey, Max(c.comppct_r) AS ComponentPercent
    FROM c
    GROUP BY c.muke;
    ) as VT, c 
    WHERE VT.mukey = c.mukey 
    

提交回复
热议问题