Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating percentages in cube 1

Status
Not open for further replies.

sagn

Programmer
Jun 7, 2001
166
US
How can one create percentage fields with a cube?

I know how to do averages and sums, but calculating
the percentage of an object is elluding me.
For example I have the following table

table 1
a b c d
a2 b2 c2 d2
a3 b3 c3 d3


I want to create a cube that will look something like this


Code:
select a,b,c,count(*),sum(d),%d
from table_1
group by 
a,b,c

with cube

where %d is the % of d out of all the d's for that section
of the cube... I am not sure if I am explaining
myself well, for which I apologize.


Any hint would be appreciated

thanks


ds
 
select a,b,c,count(*) cnt,sum(d),(select count(*) from table_1 t where t.a = table1.a) count_of_a, (select count(*) from table_1) count_all, ((count_of_a/count_all)*100) percentaje_of_a
from table_1
group by
a,b,c
John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top