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.
Author |
Topic |
SQLNoob81
Starting Member
38 Posts |
Posted - 2010-11-10 : 10:00:24
|
Hi Guys.I have 3 select statementsselect User, Sum(Fee) as TotalSales from Sales group by userselect User, Count(ID) as NoOfClients from Clients group by userselect User, Sum(SalesFee) as ValueOfQuotes from Quotes group by userI would like all 3 of these combined into one select statement to give results like this:User TotalSales NoOfClients ValueOfQuotesUser1 5000 100 2500User2 4500 120 3500User3 10000 150 7000Hope this makes sense? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-11-10 : 10:34:00
|
[code]select s.User,s.TotalSales,c.NoOfClients,q.ValueOfQuotes from (select User, Sum(Fee) as TotalSales from Sales group by user)sINNER JOIN (select User, Count(ID) as NoOfClients from Clients group by user) cON c.User = s.UserINNER JOIN (select User, Sum(SalesFee) as ValueOfQuotes from Quotes group by user)qON q.User = s.User[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
SQLNoob81
Starting Member
38 Posts |
Posted - 2010-11-11 : 01:51:25
|
Thanks visakh16U ARE THE MAN!!! |
 |
|
|
|
|