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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 % of total sum

Author  Topic 

seanh1016
Starting Member

14 Posts

Posted - 2011-01-01 : 14:50:31
trying to get the toy count % of sum of all toy counts. would this make it possible?

select*,
t.toy_count/sum(t.toy_count)
from
(
select
1 as toy_count
..
) as t

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-01-01 : 15:07:32
You need to be a little clearer... post sample data and sample desired results, along with your structures/datatypes.



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-01-02 : 04:44:45
[code]
select *,
t.toy_count / sum(t.toy_count) over()
from
(
select
1 as toy_count
..
) as t
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-03 : 04:40:24
The above method works only if the version is 2005 or later

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -