February 14, 2006 at 6:01 am
Hi all,
I am trying to do this
Consider a row having four columns which contains values as a b c d in the individual columns. I want to display the result set one below the other in the format
a
b
c
d
instead of normal a b c d
Plz help me with this.
Regards,
Sandeep
February 14, 2006 at 6:04 am
Check out the "union" command in books online. If that doesn't help, please give us your table definition, sample data and expected output of the query.
February 14, 2006 at 8:08 am
In BOL have a look at the entry for 'Pivot table' - it creates a cross-tab report displaying the data horizontaly instead of the normal vertical format.
Steve.
February 14, 2006 at 8:31 am
use your Query like this :-
select 'name_col' Col_name,
case when count(name_col) > 0 then name_col else null end value
from table_a
group by name_col
union all
select 'Rev_No' Col_Name,
convert(varchar(2),case when isnull(count(Rev_No),0) > 0 then isnull(Rev_No,0) else null end) value
from table_a
group by Rev_No
February 14, 2006 at 9:00 am
Try something like this using your table definitions:
select cast(createdate as varchar) as 'Data'
from syslogins
where name = 'sa'
union
select cast(language as varchar)
from syslogins
where name = 'sa'
union
select cast(status as varchar)
from syslogins
where name = 'sa'
union
select dbname
from syslogins
where name = 'sa'
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply