Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. Select j.JobId,
  2. case
  3. When Sum(p.Price*op.Quantity) is null then 0.00
  4. else Sum(p.Price*op.Quantity)
  5. end as [Sum]
  6. from OrderParts as op
  7. Full join Parts as p on p.PartId= op.PartId
  8. full join Orders as o on o.OrderId=op.OrderId
  9. full join Jobs as j on j.JobId=o.JobId
  10. Where j.Status='Finished'
  11. group By j.JobId
  12. Order by Sum(p.Price*op.Quantity) DESC,JobId ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement