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.
| Author |
Topic |
|
OKsoccer24
Starting Member
8 Posts |
Posted - 2008-08-13 : 11:23:53
|
| I have a table that isXX XX XX XX XX XX XXand I need it to beXXXXXXXXDoes anyone know how this is possible using SQL? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-13 : 11:27:23
|
UNPIVOT.Read Books Online for more information. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
OKsoccer24
Starting Member
8 Posts |
Posted - 2008-08-13 : 14:11:47
|
| OK I have research and find my situation from most unpivot examples.select sum(cnt_200806) as "06/08", sum(cnt_200805) as "05/08", sum(cnt_200804) as "04/08", sum(cnt_200803) as "03/08", sum(cnt_200802) as "02/08", sum(cnt_200801) as "01/08", sum(cnt_200712) as "12/07", sum(cnt_200711) as "11/07", sum(cnt_200710) as "10/07", sum(cnt_200709) as "09/07", sum(cnt_200708) as "08/07", sum(cnt_200707) as "07/07"from tbl_metrics_usersHere is my sql that post 1 row with multiple columns.. ObviouslyCan some please type the sql required the will put that in one Column. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-13 : 14:15:26
|
it will be like thisSELECT *FROM(SELECT *FROM YourTable)mUNPIVOT (Col FOR Values IN ([06/08],[05/08],...))p |
 |
|
|
OKsoccer24
Starting Member
8 Posts |
Posted - 2008-08-13 : 14:29:06
|
| I need to rephrase myself. The first post shall say that I have results from a table that equal the first post. The table tbl_metrics_users is a huge table each column having numbers that I need summed and posted in a column. The sql stmt I posted takes all the data and puts it into one row and I need one column. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-13 : 14:31:59
|
| Try putting your column headers names in unpivot query and see |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-13 : 14:36:15
|
Then post some proper sample data! And table layout. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-13 : 23:33:38
|
Have you take a look at this ?http://msdn.microsoft.com/en-us/library/ms177410.aspx? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|