Help - Search - Members - Calendar
Full Version: Percentage calculations problem, please help.
Oracle DBA Forums > Oracle > Oracle Forum
w.vie
Hi all,

I am fairly new to Oracle SQL developer and I am having an issue that may very simple but I just cannot work it out logically for some reason.

I am trying to calculate the percentage of sales each employee has made form the total of trades. I have been trying to use the COUNT function but it obviously splits the counts for each employee. I then tried a inline view but couldn't get it to work and also a sub-query and had an issue with "not a single group function" and then "not a GROUP BY expression".

Can anyone tell me how I can do this? I will also need to add the syntax to another inline view I don't know whether that will help.

Thank you in advance

w.vie
burleson
Hi,

>> add the syntax to another inline view

No! It's nbetter to keep it simple, and treat this as 4 separate queries

See here bookstore with above average sales, it's it's too complex and hard to manage (and it runs too slow!)

CODE
select
store_name,
sum(quantity) store_sales,
   (select sum(quantity) from sales)/(select count(*) from store) avg_sales from stores, sales sl
where
s.store_key = sl.store_key
having
   sum(quantity) > (select sum(quantity) from sales)/(select count(*) from store)
group bystore_name;




************************************************
>> I am trying to calculate the percentage of sales each employee has made form the total of trades.

To solve this you need to know several things:

= total trades
= sales of each employee
= number of employees

See here how to do it. Break it into separate queries!

Read this carefully, it just like the store sales query:

http://www.remote-dba.net/oracle_10g_tunin..._sql_clause.htm

I would use the WITH clause . . . .
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.