kayhustle
asked on
SQL Table Transpose
Is there a command in sql to transpose a table?
ASKER
I've never heard the term cross tab, but I'll look in the PIVOT command.
<<Is there a command in sql to transpose a table?>>
I am not familiar with that term. Could you explain what you are expecting?
I am not familiar with that term. Could you explain what you are expecting?
ASKER
Transpose is when you take a table and flip it 45 degrees so that all the columns are now rows and all rows are now columns.
<<Transpose is when you take a table and flip it 45 degrees so that all the columns are now rows and all rows are now columns.>>
Then indeed PIVOT/UNPIVOT is what you are looking for...
Hope this helps...
Then indeed PIVOT/UNPIVOT is what you are looking for...
Hope this helps...
ASKER
If I have
SELECT Date, Cost, Clicks, Impressions
FROM MyTable
GROUP BY Date
How can I pivot that statement to return each column as an individual Date?
Thanks
SELECT Date, Cost, Clicks, Impressions
FROM MyTable
GROUP BY Date
How can I pivot that statement to return each column as an individual Date?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is a command in SQL 2005 called PIVOT
In SQL 2000 there is are many workaround solutions. The best solution depends on your actual issue and what the realted systems are.
But basically a crosstab is best done in the front end, if you have one.