Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Select j.JobId,
- case
- When Sum(p.Price*op.Quantity) is null then 0.00
- else Sum(p.Price*op.Quantity)
- end as [Sum]
- from OrderParts as op
- Full join Parts as p on p.PartId= op.PartId
- full join Orders as o on o.OrderId=op.OrderId
- full join Jobs as j on j.JobId=o.JobId
- Where j.Status='Finished'
- group By j.JobId
- Order by Sum(p.Price*op.Quantity) DESC,JobId ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement