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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to hide selected column from result set?

Author  Topic 

Sanatan
Starting Member

19 Posts

Posted - 2009-05-05 : 10:39:58
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 sortcol

In 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.
Go to Top of Page

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.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-05-05 : 10:50:55
are you trying for this ??

select 
col1,col2
from
(
select col1, col2, 1 as sortcol from tbl1
union
select col1, col2, 2 as sortcol from tbl1
)s
order by sortcol
Go to Top of Page

Sanatan
Starting Member

19 Posts

Posted - 2009-05-05 : 10:58:33
Thanks Man... you were right in the last query statement!
Go to Top of Page
   

- Advertisement -