Link to home
Start Free TrialLog in
Avatar of kayhustle
kayhustle

asked on

SQL Table Transpose

Is there a command in sql to transpose a table?
Avatar of nmcdermaid
nmcdermaid

By transpose do you mean a crosstab?

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.
Avatar of kayhustle

ASKER

I've never heard the term cross tab, but I'll look in the PIVOT command.
Avatar of Racim BOUDJAKDJI
<<Is there a command in sql to transpose a table?>>
I am not familiar with that term.  Could you explain what you are expecting?
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...
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
ASKER CERTIFIED SOLUTION
Avatar of nmcdermaid
nmcdermaid

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial