Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi, I want to be able to hide a selected column from a resultset... How do I do that?Example:Query: select col1, col2, 1 as sortcol from tbl1 union select col1, col2, 1 as sortcol from tbl1 order by sortcolIn the result set, I want to only display the col1, col2 and not the sortcol. Is there any way to achieve this?
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts
Posted - 2009-05-05 : 10:43:24
remove it from select.
Sanatan
Starting Member
19 Posts
Posted - 2009-05-05 : 10:45:57
But I want the dynamic sorted order of the two resultsets....I cannt get the sorting if I remove it from select.
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts
Posted - 2009-05-05 : 10:50:55
are you trying for this ??
select col1,col2from ( select col1, col2, 1 as sortcol from tbl1 union select col1, col2, 2 as sortcol from tbl1 )sorder by sortcol
Sanatan
Starting Member
19 Posts
Posted - 2009-05-05 : 10:58:33
Thanks Man... you were right in the last query statement!