Just need to consolidate data in SQL
Basically the data is the spend information for many suppliers, I need to churn out just the supplier name along with a sum of their amounts spent/ volume.
I need to get FROM THIS:
Company Contract Amount Spent Volume
Shell Oil Shell891 10 100
Shell Oil Shell892 20 200
BP BP0001 50 1
BP BP0001 100 2
TO THIS
Company Amount Spent Volume
Shell Oil 30 300
BP 150 3
Etc
So I need a query that can add both the amount spent and volume and then remove DISTINCT company name rows. I understand the basics of SQL but sub-queries start to confuse me!
I would be eternally grateful for any help/ advice/ tips.
Many, many thanks!Use SUM and GROUP BY as in this simple example:
SELECT deptno, SUM(sal) AS deptsal
FROM emp
GROUP BY deptno;|||please don't cross-post
http://www.dbforums.com/t1005683.html
Friday, February 10, 2012
Consolidation Query
Labels:
along,
churn,
consolidate,
consolidation,
database,
microsoft,
mysql,
oracle,
query,
server,
sql,
sqlbasically,
supplier,
suppliers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment