Hi,
Joining or Combining Select Statements in SQL Server
Joining or Combining Select Statements in SQL Server
SELECT * FROM
(SELECT Person, COUNT(*) AS '# Tasks' FROM Table GROUP BY Person) t1
INNER JOIN
(SELECT Person, COUNT(*) AS '# Late' FROM Table WHERE Age > 30 GROUP BY Person) t2
ON t1.Person= t2.Person
Three Select Statements
SELECT *
FROM
(SELECT Product, SUM(QTY) FROM Table1 GROUP BY ID) K1
JOIN
(SELECT Product, SUM(QTY) FROM Table2 GROUP BY ID) K2
ON K1.Product = K2.Product
JOIN
(SELECT Product, SUM(QTY) FROM Table3 GROUP BY ID) K3
ON K1.Product = K3.Product
Comments
Post a Comment