Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
and i am looking for T-sql that produce the result as
PRCd Ctg Cost AB CD EF XM====================================================Cost 4578 500 500 252 824 898Cost 9579 500 5000 2520 8240 8980....
Please help.
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts
Posted - 2010-01-21 : 14:05:43
This?
select 'Cost' as [PRCd],Ctg,max(case when PRCd = 'AB' then Cost else null end) as [AB],max(case when PRCd = 'CD' then Cost else null end) as [CD],max(case when PRCd = 'EF' then Cost else null end) as [EF],max(case when PRCd = 'XM' then Cost else null end) as [XM]from table1group by Ctg
If [PRCd] values are dynamic , search for 'dynamic cross tabs' here.