Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi,I'm having a problem calculating some percentages on columns and I'm not sure what I'm doing wrong: In the table below, I'm trying to calculate the Percent of Q1 based on the total so for User = Joe, it should be as follows 50/Sum(50 + 10 + 75) = 37%. When I try to calculate this in SQL, i'm getting 0 in the percent of Q1 column: select User, Sum(Q1 + Q2 + Q3)/Q1 as Percent of Q1From Table1where User = Joe -- this query returns zero when it should return 37%User: Q1 Q2 Q3 PERCENT OF Q1 Joe 50 10 75Bill 2 8 40Lisa 10 5 20