Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Aggregates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-28-03, 23:54
Tnu4 Tnu4 is offline
Registered User
 
Join Date: Nov 2003
Posts: 3
Aggregates

Hey all... I'm very new to SQL and in search of a good source of information. These forums seem to be perfect from what I've seen.

Right now I'm in search of help on a problem. I have a table which lists sales (ID, Date, SaleAmt). From this table a View has been Created to sum all the sales for the ID (EmpID, Tot_Sales). What I'm trying to do is create a report to show the percentage of total sales each ID has. So it would be something like Tot_Sales/SUM(Tot_Sales), however, nothing I've tried thus far has worked. Can anybody please help with this?
Reply With Quote
  #2 (permalink)  
Old 12-01-03, 00:08
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
What sql are you using (SQL Server, Oracle, Informix ...) ?
Reply With Quote
  #3 (permalink)  
Old 12-01-03, 03:47
Tnu4 Tnu4 is offline
Registered User
 
Join Date: Nov 2003
Posts: 3
It's out of a Microfocus product, and I believe its IBM DB2.
Reply With Quote
  #4 (permalink)  
Old 12-01-03, 09:51
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
Your Comment->
"So it would be something like Tot_Sales/SUM(Tot_Sales), however, nothing I've tried thus far has worked"

This is correct, except for 'GROUP BY x' where x is the/many columns projected in the select statement that are not aggregate functions.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
Reply With Quote
  #5 (permalink)  
Old 12-01-03, 13:40
Tnu4 Tnu4 is offline
Registered User
 
Join Date: Nov 2003
Posts: 3
Thank you both for the help. I've found the problem in incorrect usage of the group by clause.

Thanks
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On