Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select p.ProductId
- ,sum(od.Quantity) as TotalQuantity
- from Products p
- join [Order Details] od
- on p.ProductId=od.Productid
- group by p.ProductId
- select p.productid
- ,p.ProductName
- , sum(od.quantity) as TotalQuantity
- from products p
- join [Order details] od
- on p.productid=od.productid
- group by p.productid
- Msg 8120, Level 16, State 1, Line 1
- Column 'products.ProductName' is invalid in the select list because
- it is not contained in either an aggregate function or the GROUP BY clause.`
- select p.productid, p.ProductName, sum(od.quantity) as TotalQuantity from
- products p join [Order details] od on p.productid=od.productid
- group by p.productid, p.ProductName
- select p.productid
- , min(p.ProductName) as ProductName
- , sum(od.quantity) as TotalQuantity
- from products p
- join [Order details] od
- on p.productid=od.productid
- group by p.productid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement