我的表:
PageOrderID PageName
3 Citation Number
3 Citation Number
3 Citation Number
1 Account Info
1 Account Info
1 Account Info
我想根据PageOrderID订购Pagename,但是不同的PageNames。
我尝试了以下但是它无效:
select PageOrderID,distinct(PageName) from ScreenMaster order by PageOrderID
错误是什么?
O / P:
PageOrderID PageName
1 Account Info
3 Citation Number
答案 0 :(得分:5)
select DISTINCT PageOrderID,PageName from ScreenMaster
order by PageOrderID
答案 1 :(得分:3)
也许你想分组:
SELECT PageOrderID,PageName
FROM dbo.ScreenMaster
GROUP BY PageOrderID,PageName
ORDER BY PageOrderID
PAGEORDERID PAGENAME
1 Account Info
3 Citation Number
答案 2 :(得分:2)
很简单,
select distinct * from ScreenMaster
order by PageOrderID
答案 3 :(得分:1)
试试这个
select DISTINCT PageOrderID,PageName from ScreenMaster group by PageOrderID,PageName order by PageOrderID