New answers tagged

-1 votes

How to Join two tables with SUM and GROUP BY in SQL server

SELECT Designation, SUM(Qty) FROM Product P JOIN sub_product Q ON Q.Product_ID = P.id GROUP BY Designation ORDER BY Designation ? downvoted? LOL DECLARE @Product TABLE (ID INT, Designation VARCHAR(10)...
user avatar
  • 333
3 votes
Accepted

How to Join two tables with SUM and GROUP BY in SQL server

This can be accomplished simply with a JOIN and GROUP_BY clause like so: SELECT p.designation, SUM(ISNULL(sp.quantity, 0)) AS [total quantity] FROM product AS p LEFT JOIN sub_product AS sp ...
user avatar
  • 24.2k

Top 50 recent answers are included