Click here to Skip to main content
15,904,500 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

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

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


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
Posted
Comments
scottgp 12-Feb-14 7:58am    
Why are you trying to include the "order by" in the subquery? Why even have the subquery here? It doesn't seem to be serving any purpose.
[no name] 12-Feb-14 8:00am    
I need a ascending order of UUSLaminates.
[no name] 12-Feb-14 8:01am    
according to UUSLaminateName

1 solution

This will do:
SELECT UUSLaminateThumbnailImage,UUSLaminateImage,UUSLaminateName,percentAdded FROM UUSLaminates WHERE UUSLaminateID=@imgId order by UUSLaminateName asc 
 
Share this answer
 
Comments
[no name] 12-Feb-14 8:10am    
No,
I want to first sorting and then Where condition apply.,
Pete O'Hanlon 12-Feb-14 8:31am    
Why? Sorting post where condition will still put the data into the correct order.
Peter Leow 12-Feb-14 8:57am    
The order of records in the table does not matter, what does matter is the ordered output from your sql query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900