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 |
|
mufasa
Yak Posting Veteran
62 Posts |
Posted - 2004-08-05 : 14:57:05
|
Hi I am trying to transform columns into rowsexample:Existing tablec1=Date, c2=Store, c3=VisaAmount, c4=MCAmount, c5=DebitAmount.View WantedI need to create a view with the followingc1=Date, c2=Store, c3=Cardtype, c4=AmountThanks Mufasa |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-08-05 : 15:16:46
|
| [code]USE NorthwindGOCREATE TABLE myTable99( [Date] datetime , Store varchar(25) , VisaAmount money , MCAmount money , DebitAmount money)GOINSERT INTO myTable99([Date], Store, VisaAmount, MCAmount, DebitAmount)SELECT '1/1/2004','Home Depot',12424.1234,2656.24,9345GOCREATE VIEW myView99ASSELECT [Date], Store, 'Visa' AS CardType, VisaAmount AS Amount FROM myTable99UNION ALLSELECT [Date], Store, 'MC' AS CardType, MCAmount AS Amount FROM myTable99UNION ALLSELECT [Date], Store, 'Debit' AS CardType, DebitAmount AS Amount FROM myTable99GOSELECT * FROM myView99DROP VIEW myView99DROP TABLE myTable99GO[/code]Brett8-) |
 |
|
|
mufasa
Yak Posting Veteran
62 Posts |
Posted - 2004-08-05 : 15:54:07
|
| Thanks BrettWorks greatMufasa |
 |
|
|
|
|
|
|
|