2

我的桌子:

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

错误是什么?

输出/输出:

PageOrderID   PageName
1              Account Info
3              Citation Number
4

4 回答 4

5
select DISTINCT PageOrderID,PageName from ScreenMaster
order by PageOrderID 
于 2013-07-18T11:22:02.503 回答
3

也许您想按以下方式分组:

SELECT PageOrderID,PageName
FROM dbo.ScreenMaster 
GROUP BY PageOrderID,PageName
ORDER BY PageOrderID

演示

PAGEORDERID     PAGENAME
    1           Account Info
    3           Citation Number
于 2013-07-18T11:23:20.913 回答
2

很简单,

select distinct * from ScreenMaster 
order by PageOrderID
于 2013-07-18T11:26:24.120 回答
1

尝试这个

select DISTINCT PageOrderID,PageName from ScreenMaster group by PageOrderID,PageName order by PageOrderID
于 2013-07-18T12:48:20.043 回答