sql distinct,怎么排序sql加了distinct想要用时间排序

伏羲号

sql distinct,怎么排序sql加了distinct想要用时间排序?

distinct 本身只是过滤重复的行,排序使用order by 子句 ,where子句提供筛选条件。sql="select distinct lb2 from gllb where lb1='"&request.QueryString("lb1")&"' order by 时间列"

sql distinct,怎么排序sql加了distinct想要用时间排序

在sql语句中用了distinct还怎么用orderby?

distinct 和 order by 是可以一起用的。

distinct :消除重复行

order by:排序

同时使用时,先消除重复行,然后排序

例表table:

a

1

3

1

2

select distinct a from table order by a

检索结果为;

a

1

2

3

发表评论

快捷回复: 表情:
AddoilApplauseBadlaughBombCoffeeFabulousFacepalmFecesFrownHeyhaInsidiousKeepFightingNoProbPigHeadShockedSinistersmileSlapSocialSweatTolaughWatermelonWittyWowYeahYellowdog
评论列表 (暂无评论,75人围观)

还没有评论,来说两句吧...