標題:
[發問]
SQL查詢請教?
[打印本頁]
作者:
joey0415
時間:
2010-8-4 18:38
標題:
SQL查詢請教?
小弟有一個資料庫,想從中找到以「
stockid
」排列,並且再取「
序號
」最大值的語法?
小弟只會寫成這樣?
select stockid,MAX(序號) from AAA group by stockid order by stockid,不知有哪位高手可以指點一下
謝謝
[attach]2196[/attach]
作者:
kimbal
時間:
2010-8-4 21:59
select aaa.* from aaa,
(select stockid, MAX(序號) as MAXA from AAA
group by stockid) bbb
where aaa.stockid = bbb.stockid
and aaa.序號 = bbb.maxa
order by aaa.stockid
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)