Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Order by and parameters
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00727721
Message ID:
00727767
Views:
8
Crescencio,

Thank you.
The article gave lots of ways and was very informative to my current level.
The multiple case statements method worked best for sorting by all columns of a datagrid, and then the ascending/descending part I could not get to work because one field was a count(1) as hits involved in the group by username aggregation was not being recognized as a valid column.

So I made my main query a sub-query without an order by clause and then ordered by in the super query. This worked fine then for all cases.

Thanks again for such a quick reply.

>Check out http://www.sqlmag.com/Articles/Index.cfm?ArticleID=16495 HTH
>
>>Can someone tell me how one used parameters in the order by clause to get some dynamic ordering without dynamic query building?
>>
>>when I use:
>>group by username
>>order by @sortFld
>>I get:
>>variables are only allowed when ordering by an expression referencing a column name.
>>
>>Should I use case structures in order by clause?
>>I've had problems with that in context of group by
>>
>>or a if structure?
>>
>>TIA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform