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 |
tygun1
Starting Member
1 Post |
Posted - 2004-05-20 : 14:04:11
|
I am trying to utilize the Sum() function to create a calculated member tha ultimately gives me the percent of the total count.Heres a simplified scenarioI have a Measure called Product Group. Lets say I have 3 productsapples, oranges, coconutsNow lets say I have a measure that counts the orders for these so the data would look like thisProduct Count of ordersAll 100Oranges 30Apples 50Coconuts 20I want a calculated member that would give me the percentage of orders that each product represents (i.e. the column next to the oranges count would be 30% becasue 30 orders out of 100 is 30%, and so on). I thought this would be a piece of cake, but I guess I'm not that smart. Can someone please help me with this.Thanks in advance, Scott |
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2004-05-20 : 14:25:04
|
Try something like this:SELECT Product, count(orders)/((select count(b.orders) from myTable b)* 1.00)from myTableGROUP BY Product |
|
|
|
|
|