Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Calculate percentage (2)

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
johnkainn
Asked:
johnkainn
1 Solution
 
momi_sabagCommented:
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
 
Jagdish DevakuSr DB ArchitectCommented:
can u give the link of your previous post...???
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now