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.
Could you help me get the percentage of pending and cleared records from the below table and add it to this query?SELECT reg, regname,sum(MMPending) as MMPend, sum(RecPending) as RecPend, sum(MMPendingCleared) as MMCleared,sum(RecPendingCleared) as RecCleared FROM Totalsgroup by reg, regnameorder by reg
selecttt.reg,tt.regname,cast((tt.MMCleared*1.0/tt.MMPend)*100 as decimal(7,2)) as PendingPercent,cast((tt.RecCleared*1.0/tt.RecPend)*100 as decimal(7,2)) as ClearedPercentfrom(SELECT reg, regname,sum(MMPending) as MMPend,sum(RecPending) as RecPend,sum(MMPendingCleared) as MMCleared,sum(RecPendingCleared) as RecClearedFROM Totalsgroup by reg, regname--order by reg)as ttorder by tt.reg
JJ297
Aged Yak Warrior
940 Posts
Posted - 2010-08-24 : 11:23:50
Thanks that worked but It's only displaying four columns:RegRegnamePendingPercentClearedPercentHow do I get it to display:MMPending,RecPending,MMPendingClearedRecPendingCleared
JJ297
Aged Yak Warrior
940 Posts
Posted - 2010-08-24 : 11:28:20
Never mind I got it. I added them to the select statement. Thanks so much!