We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

how can I get a percentual in my query from a total field?

hidrau
hidrau asked
on
Medium Priority
329 Views
Last Modified: 2012-06-27
Hello guys

I have this query:

SELECT CLIENT, TOTAL FROM SELL

Unless I have the Total, I want the percentual

is it possible? thanks
Comment
Watch Question

Imran Javed ZiaConsultant Software Engineer - .NET Architect
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Commented:
sorry miss the @ before sumTotal
Declare @sumTotal float
select @sumTotal = sum(TOTAL) from SELL

SELECT CLIENT, TOTAL, (TOTAL / @sumTotal) as [Percentage] FROM SELL

Open in new window

CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
THANKS VERY MUCH

Commented:
you must select the sum of Total in a variable separately in-order to enhance performance
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.