We help IT Professionals succeed at work.

Sql Server 2005, Convert column to rows

I have a query that returns me data like what I have below...
Temp1_TS                                         Temp2_TS
NULL                                             2011-11-01 18:08:59.883
2011-11-02 03:01:45.843            NULL

I would really like to have:
Temp1_TS                                         Temp2_TS
 2011-11-02 03:01:45.843               2011-11-01 18:08:59.883


I tried using Coalesce(Temp1_TS, Temp2_TS), but that gives me a single column with 2 rows.  I need a single row, with 2 correctly named columns.

thanks,
rgn
Comment
Watch Question

Sr. System Analyst
CERTIFIED EXPERT
Commented:
try:

select max(temp1_ts) temp1_ts, max(temp2_ts) temp2_ts
from (
your query here
) x

this works if you always have two records... are these the only columns & rows?

Author

Commented:
this is before the coalesce correct?

Author

Commented:
Thanks!  I will always only have 2 columns, not possible about rows.  I will have to look into that...

Author

Commented:
Sorry, I meant, "Not sure about rows.."

Explore More ContentExplore courses, solutions, and other research materials related to this topic.