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 |
|
scottichrosaviakosmos
Yak Posting Veteran
66 Posts |
Posted - 2010-10-15 : 12:59:53
|
| I have two tables:one with name tblmonth and another with name tbldate as follows:tblmonth:stdid code jan feb march april may100 A 10 12 50 21 30100 B 12 11 9 6 45101 A 12 65 45 34 23101 B 34 32 12 56 34tbldate:stdid sdate eddate100 01/02/2010 04/05/2010101 02/03/2010 04/02/2010Now, i want my result as following :stdid eddate A B 100 04/05/2010 if(jan)then feb+mar+april+may feb + mar + april+may if(feb) then mar+april+may mar+april+mayI have tried pivot for first tableselect * from tblmonthpivot(sum(jan) for jan in([jan],[feb])as tbut i m geting data only for jan and not for feb, march .. etc.And even after getting all data how can i get my above desired output.scoo |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|