Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
drsloat
Starting Member
45 Posts |
Posted - 2001-09-17 : 16:33:09
|
| I am writing a stored procedure w/ a Union claus as follows:(select l.LibraryContentID, l.FileTitle, l.LastNamefrom LibraryContent l Where ... ) Union ( select l.LibraryContentID, l.FileTitle, l.LastNamefrom LibraryContent l Where ...) Order by (Case @Sort When 0 Then l.FileTitle Else l.LastName End)I've used this kind of case statement in an order by claus before, but now I get the error that the order by field must be included in the select list of a union query. I could accept that...but if I take out the Case statement I can sort on either of these fields. I'm curious as to why it works outside the case statement, but not in it.I guess this might be a picky question, but am I missing something or should I just try a different approach? |
|
|
|
|
|