order by clause不工作 [英] order by clause not working

查看:102
本文介绍了order by clause不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

;  一个  

选择 top 100 百分比 1 as t,t1.regId as a,t1.visitCount as b
来自 registerdata as t1 order by t1 .visitCount desc

,两个

选择 top 100 百分比 2 as t,t1.regId,t1。 visitC
来自 registerdata as t1

选择 * 来自一个
union
选择 * 来自两个订单 by t desc





这是我的查询,我想要第一个查询顺序。它运行但结果显示错误..

请给出任何解决方案。

解决方案





使用以下查询



 选择 * 来自选择  top   100  百分比  1   as  t,t1.regId,t1.visitCount 
来自 registerdata) as t1
订单 t1.visitCount desc






我没有得到,你为什么要使用sub -QUERY?您的简单查询将起作用并提供所需的输出。



 选择  top   100  百分比  1   as  t,t1.regId,t1.visitCount 来自 registerdata  as  t1  order   by  t1.visitCount < span class =code-keyword> desc  









如果你正在使用工会,请查看下面的查询...



现在尝试这个....只是按顺序添加了desc with 1。



 选择  top   100  百分比  1   as  t,t1.regId,t1.visitCount 来自 registerdata  as  t1 
union
- 这里我假设您的查询的下一部分。
选择 top < span class =code-digit> 100 百分比 2 as t,t2.regId,t2.visitCount 来自 table2 as t2
订单 1 < span class =code-keyword> desc , 3 desc











希望这会对你有帮助。


试试这个代码....



SELECT * FROM(

选择前100%1作为t,t1.regId,t1 .visitCount
来自registerdata的
为t1

)as yy ORDER BY yy.visitCount desc


;with One as
(
    select top 100 percent 1 as t,t1.regId as a, t1.visitCount as b
     from registerdata as t1 order by t1.visitCount desc 
)
,Two as
(
    select top 100 percent 2 as t,t1.regId, t1.visitCount
    from registerdata as t1
)
select * from One
union
select * from Two order by t desc



this is my query and i want first query order by . it's run but result are shown wrong ..
please give any solution.

解决方案

Hi,

Use below Query

select * from (select top 100 percent 1 as t,t1.regId, t1.visitCount
    from registerdata) as t1
   order by t1.visitCount desc


Hi,

I am not getting, why are you using sub-query? Your simple query will work and give the required output.

select top 100 percent 1 as t,t1.regId, t1.visitCount from registerdata as t1 order by t1.visitCount desc





Also check below query if you are using union...

now try this....just added desc with 1 in order by clause.

select top 100 percent 1 as t,t1.regId, t1.visitCount from registerdata as t1 
union
--here i am assuming next part of your query.
select top 100 percent 2 as t,t2.regId, t2.visitCount from table2 as t2 
order by  1 desc , 3 desc






Hope this will help you.


Try this code....

SELECT * FROM (
select top 100 percent 1 as t,t1.regId, t1.visitCount
from registerdata as t1
) as yy ORDER BY yy.visitCount desc


这篇关于order by clause不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆