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?What sql are you using (SQL Server, Oracle, Informix ...) ?|||It's out of a Microfocus product, and I believe its IBM DB2.|||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.|||Thank you both for the help. I've found the problem in incorrect usage of the group by clause.
Thanks :)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment