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 |
|
dev45
Yak Posting Veteran
54 Posts |
Posted - 2004-09-23 : 09:29:02
|
| i have a query that goes something like :select StringA as str from tableA inner join(s).... where.....unionselect case aNumberVariable when 0 then stringB when 1 then stringC else stringD end as str from tableAi don't mind about the order of the 1st select records but i want that the result of the second string (string B,C or D) to be the last one is there a way ? |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2004-09-23 : 09:38:23
|
| Return a constant in the query such that you can be sure of the order. I.e.SELECT 1 AS SortOrder, StringA as strFROM tableAINNER JOIN(s)...WHERE...UNION SELECT 2, CASE aNumberVariableWHEN 0 THEN stringBWHEN 1 THEN stringCELSE stringDEND as strFROM tableAORDER BY SortOrderMark |
 |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2004-09-23 : 09:40:41
|
| HTH..Select str from (Select '1' as order_Col, StringA as str from table A .... UnionSelect '2', Select case......) as A order by A.order_col- Sekar |
 |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2004-09-23 : 09:41:49
|
| Oh. not again .. I am Late.. Damn slow internet connections..- Sekar |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2004-09-23 : 09:54:30
|
I know your pain Sekar, I'm usually on the receiving end! Mark |
 |
|
|
|
|
|