有什么办法可以在SQL中的where条件之前编写'ORDER BY'子句? [英] Is there any way to write 'ORDER BY' clause before where condition in sql?

查看:127
本文介绍了有什么办法可以在SQL中的where条件之前编写'ORDER BY'子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在根据自己的条件使用此查询,但出现错误:-

Hello,

I am using this query according to my condition but it''s getting error:-

select * from(SELECT UUSLaminateThumbnailImage,UUSLaminateImage,UUSLaminateName,percentAdded FROM UUSLaminates order by UUSLaminateName asc) WHERE UUSLaminateID=@imgId



除非还指定了TOP或FOR XML,否则ORDER BY子句在视图,内联函数,派生表,子查询和公用表表达式中无效.
请帮帮我.

在此先感谢.

安吉·阿加瓦尔
软件工程师



The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.

Please help me.

Thanks in Advance.

Ankit Agarwal
Software Engineer

推荐答案

这可以做到:
This will do:
SELECT UUSLaminateThumbnailImage,UUSLaminateImage,UUSLaminateName,percentAdded FROM UUSLaminates WHERE UUSLaminateID=@imgId order by UUSLaminateName asc 


这篇关于有什么办法可以在SQL中的where条件之前编写'ORDER BY'子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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