如何在sql查询中使用order [英] how to use order by in sql query
本文介绍了如何在sql查询中使用order的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sql查询中使用order
-------------------------------
这里使用
SELECT
DISTINCT
其中
我想在此查询中使用Order by子句。按升序显示SCH_TIME(计划时间)。
这是我的代码。
SqlCommand cmd = new SqlCommand( < span class =code-string>选择DISTINCT Flightno,DESCR,substring(SCH_TIME,10,4)作为来自DFlights的ScheduleTime,Destination,Status,Gate(INT_DOM ='I'和ARR_DEP ='D'),con);
请帮帮我。
,感谢您的帮助。
谢谢。
解决方案
SqlCommand cmd =新的SqlCommand(选择DISTINCT Flightno,DESCR,子串(SCH_TIME,10,4)作为ScheduleTime,目的地,状态,来自DFlights的门,其中(INT_DOM ='I'和ARR_DEP ='D')按子串排序(SCH_TIME,10, 4),con);
order by子句应始终放在where子句
之后
查看s ...
选择 DISTINCT Flightno,
DESCR,
substring(SCH_TIME, 10 , 4 ) as ScheduleTime,
Destination,
Status,
Gate
来自
DFlights
其中
INT_DOM = ' 我' 和 ARR_DEP = ' D'
订单 按 3
希望这个会帮助你。
干杯
你也可以用以下格式做同样的事情
SqlCommand cmd = new SqlCommand(选择DISTINCT Flightno,DESCR,substring(SCH_TIME,10,4)作为ScheduleTime,Destination,Status,来自DFlights的门,其中(INT_DOM ='I'和ARR_DEP ='D')按3,con)排序;
how to use order by in sql query
-------------------------------
here am using
SELECT
DISTINCT
Where
and I want to use Order by clause in this query. to display SCH_TIME(Schedule Time) in Ascending order.
This is my code.
SqlCommand cmd = new SqlCommand("Select DISTINCT Flightno,DESCR,substring(SCH_TIME,10,4) as ScheduleTime,Destination,Status,Gate from DFlights where(INT_DOM='I' and ARR_DEP='D')", con);
Please can you help me.
your help is appreciated.
Thanks.
解决方案
SqlCommand cmd = new SqlCommand("Select DISTINCT Flightno,DESCR,substring(SCH_TIME,10,4) as ScheduleTime,Destination,Status,Gate from DFlights where(INT_DOM='I' and ARR_DEP='D') order by substring(SCH_TIME,10,4)", con);
order by clause should always place after where clause
Hi,
Check this...
Select DISTINCT Flightno, DESCR, substring(SCH_TIME,10,4) as ScheduleTime, Destination, Status, Gate from DFlights where INT_DOM='I' and ARR_DEP='D' Order By 3
Hope this will help you.
Cheers
You can also do the same using following format
SqlCommand cmd = new SqlCommand("Select DISTINCT Flightno,DESCR,substring(SCH_TIME,10,4) as ScheduleTime,Destination,Status,Gate from DFlights where(INT_DOM='I' and ARR_DEP='D') order by 3", con);
这篇关于如何在sql查询中使用order的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文