Solved

Calculate percentage (2)

Posted on 2009-06-29
2
191 Views
Last Modified: 2012-05-07
See earlier post.

When I test the code I get following result:
50,100,75,25
but I should get: 20,40,30,10
How can I fix this?
0
Comment
Question by:johnkainn
2 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 24734746
sorry
i had a mistake
try this

select distinct id, 100*sum(units) over(partition by id) / sum(units) over() as Unitspercentage
from myTable
0
 
LVL 14

Expert Comment

by:Jagdish Devaku
ID: 24734822
can u give the link of your previous post...???
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Server Remove all trailing commas 10 72
passing parameter in sql procedure 9 57
Order by but want it in specific order 2 26
Delete from table 6 46
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now