Percent of total

Percent of total

Post by Gary » Wed, 03 Mar 2004 03:51:44



MyTable is as follows:
Name    Revenue
Joe        300
Mary     400
Ed         200

I want to list the table along with each persons percent of the total
Revenue.  How can I do this?
Thanks,
G

 
 
 

Percent of total

Post by David Porta » Wed, 03 Mar 2004 04:04:36


SELECT name,
 CAST(revenue/
 (SELECT SUM(revenue)/100.0
  FROM SomeTable) AS NUMERIC(5,2)) AS pct
 FROM SomeTable

--
David Portas
SQL Server MVP
--

 
 
 

Percent of total

Post by Stephen Hendrick » Wed, 03 Mar 2004 04:50:47


Slight variation...


begin tran

from SomeTable


from SomeTable
commit tran

HTH

=======================================
Everyone here speaks SQL; some are more fluent, others less.  When
describing your SQL object (table, etc.), do so in the language that we
all understand - SQL, not English.  It makes it easier to understand
your issue and makes it more likely that you will get the assistance
that you are asking for.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

Percent of total

Post by Gary » Wed, 03 Mar 2004 05:18:14


David:
Thanks so much.
Gary


Quote:> SELECT name,
>  CAST(revenue/
>  (SELECT SUM(revenue)/100.0
>   FROM SomeTable) AS NUMERIC(5,2)) AS pct
>  FROM SomeTable

> --
> David Portas
> SQL Server MVP
> --

 
 
 

1. Calculated member - Percent of total

Hi,
I have a measure: [NoOfCases], and a dimention: [Departments]
I want to build a calculate member: [PercentOfTotal], that will be the value
of [NoOfCases] for a specific department divided by that value for all
department.
Can yo please provide me the MDX syntax?
Thank you,
Nurit

2. Job Listings for Computer Professionals in the Dallas-Fort Worth area

3. SQL: Percent of total count

4. Urgent ... Recuperation d'une bdd

5. OLAP Calculated member for percent of total revenue.

6. Upgrading from pdoxdos 4.0 to pdoxdos 4.5

7. MDX:Acumulated percent or total

8. WebDB - Removing Admin icon

9. percent of total in a GROUP BY

10. Percent of Total Query Help

11. SQL question: figuring percents on totals

12. Percent of Total in Crystal 4.5 Cross Tab Report

13. Percent column working at break key totals - How