combining results of two select statements
- by ErnieStings
I'm using T-SQL with ASP.NET, and c# and i'm pretty new to SQL.
I was wondering how i could combine the results of two queries
Query1:
SELECT tableA.Id, tableA.Name, [tableB].Username AS Owner, [tableB].ImageUrl, [tableB].CompanyImageUrl, COUNT(tableD.UserId) AS NumberOfUsers
FROM tableD RIGHT OUTER JOIN
[tableB] INNER JOIN
tableA ON [tableB].Id = tableA.Owner ON tableD.tableAId = tableA.Id
GROUP BY tableA.Name, [tableB].Username, [tableB].ImageUrl, [tableB].CompanyImageUrl
Query2:
SELECT tableA.Id, tableA.Name, COUNT([tableC].Id) AS NumberOfPlans
FROM [tableC] RIGHT OUTER JOIN
tableA ON [tableC].tableAId = tableA.Id
GROUP BY tableA.Id, tableA.Name
Any help would be much appreciated.
Thanks in advance