Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Inner join and groupe result

Author  Topic 

duf
Starting Member

39 Posts

Posted - 2012-03-26 : 09:43:20
How to write a query that will join tables and sum up the results of queries?

After the join I have a query result:
123456 | 10
123456 | 02

And I would have the result of such:
123456 | 12

A query looks like this:
SELECT WAR, WAL FROM IDCN INNER JOIN IDWARTOSC 
ON IDCN.CNID=IDWARTOSC.CNID WHERE IDCN.CNID=1;

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-26 : 09:48:55
[code]
SELECT WAR, SUM(WAL) FROM IDCN INNER JOIN IDWARTOSC
ON IDCN.CNID=IDWARTOSC.CNID WHERE IDCN.CNID=1
GROUP BY WAR
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

duf
Starting Member

39 Posts

Posted - 2012-03-27 : 03:58:32
Thanks, but without: "GROUP BY WAR"
Go to Top of Page
   

- Advertisement -