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
 General SQL Server Forums
 New to SQL Server Programming
 MS QUERY HELL

Author  Topic 

shebert
Yak Posting Veteran

85 Posts

Posted - 2009-07-21 : 16:25:45
Hello
I a DBA who has been attacked by a Fiancial analyst to find him an answer to his msquery issue. spituy

The issue is with renameing column heading is MS query.

ok here it goes

select columna,columnb,columna+columnb as "combine from
testTable where columna=1

this works fine
you get:
columna columnb combine
1 1 2

when I union I lose the column heading of combine any ideas why?


select columna,columnb,columna+columnb as "combine from
testTable where columna=1
union
select columna,columnb,columna+columnb as "combine from
testTable where columna=4

you get:
columna columnb
1 1 2

4 2 6

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-21 : 16:32:01
select columna, columnb, columna + columnb as [combine]
from testTable where columna = 1
union
select columna, columnb, columna + columnb as [combine]
from testTable where columna = 4



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

shebert
Yak Posting Veteran

85 Posts

Posted - 2009-07-21 : 16:35:46
That worked Thanks
Go to Top of Page
   

- Advertisement -