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 |
|
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-24 : 13:00:31
|
| empno month1 month2 month3 all months1001 162.333650 250.000000 450.000000 g1002 300.000000 350.000000 500.000000 g1003 200.000000 450.000000 600.000000 g-----------------------------------------------------------Total: 662.333650 1050.000000 1550.000000 g------------------------------------------------------------I want to replace all months (g) with total month1+month2+month3I used the following pivot Scriptselect emp_no,[1] ,[2],[3],'g' from( select case when emp_no is null then 'Total:>' else CAST (emp_no as nvarchar) end as emp_no ,months,sum(salary) as salary from AAA group by cube( months, emp_no)) sourced pivot ( sum(salary) for months in([1],[2],[3]) )pvt |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
|
|
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-24 : 13:10:56
|
| sorry for duplicate it is not intended post.I want to use a simple way, to generate a view then connect it with crystal report 2008.I want to do it using Pivot,Compute By,grouping sets,cube,rollup methods.thank you; |
 |
|
|
|
|
|
|
|