亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

選擇每個組的最大值

選擇每個組的最大值

紫衣仙女 2019-09-24 10:47:11
Name    Value   AnotherColumn-----------Pump 1  8000.0  Something1Pump 1  10000.0 Something2Pump 1  10000.0 Something3Pump 2  3043    Something4Pump 2  4594    Something5Pump 2  6165    Something6我的桌子看起來像這樣。我想知道如何為每個泵選擇最大值。select a.name, value from out_pumptable as a,(select name, max(value) as value from out_pumptable where group by posnumber)g where and g.value = value這段代碼可以完成工作,但是我得到了Pump 1的兩個條目,因為它有兩個具有相同值的條目。
查看完整描述

3 回答

?
白板的微信

TA貢獻1883條經驗 獲得超3個贊

select name, max(value)

from out_pumptable

group by name


查看完整回答
反對 回復 2019-09-24
?
MM們

TA貢獻1886條經驗 獲得超2個贊

select name, value 

from( select name, value, ROW_NUMBER() OVER(PARTITION BY name ORDER BY value desc) as rn

from out_pumptable ) as a

where rn = 1


查看完整回答
反對 回復 2019-09-24
  • 3 回答
  • 0 關注
  • 475 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號