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 |
Sanatan
Starting Member
19 Posts |
Posted - 2009-04-01 : 14:22:48
|
Hi, I need some quick help with a sorting issue.I have two sets of data retrieved from a table and joined via a UNION.I need to display the first set of data always above the second set. Is there any quick way to do this?Data example:SELECT Col1, Col2 from TblA Where (Col1 matching subquery1) <- Set1unionSELECT Col1, Col2 from TblA Where (Col1 matching subquery2) <- Set2I want the final result set to be shown in the same order as the above query.Please let me know if you need additional details. Thanks, |
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-04-01 : 14:38:21
|
[code]Select Col1, Col2from(SELECT Col1, Col2,1 id from TblA Where (Col1 matching subquery1) <- Set1unionSELECT Col1, Col2,2 from TblA Where (Col1 matching subquery2) <- Set2)sorder by id[/code] |
|
|
Sanatan
Starting Member
19 Posts |
Posted - 2009-04-01 : 14:42:28
|
Thanks Sakets... I just got it to work! Anyway, appreciate your quick help. |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-04-01 : 14:43:42
|
np |
|
|
|
|
|