TheRogueWolf
IS-IT--Management
Hi, I'm new to SQL queries but I think I've got the hang of the basics. I have a problem which I'm not sure how to proceed with, however, and I'm hoping someone can help.
I have two tables:
Supplier
- suppliernum
- name
OrderDetail
- suppliernum
- orderqty
- unitcost
My aim is to get a list of all suppliers (including suppliers with no orders) showing the total value of orders raised against each one (zero for suppliers with no orders).
Unfortunately, the OrderDetail table holds order lines but doesn't hold a line value, just quantity and unit price for each line on an order.
So, I assume I need to multiply 'orderqty' by 'unitcost' for each line in the OrderDetail table then sum the result by supplier and join that to the Supplier table using 'suppliernum' to display the supplier name.
Could someone let me know if I'm looking at this the right way and maybe suggest an SQL example?
I have two tables:
Supplier
- suppliernum
- name
OrderDetail
- suppliernum
- orderqty
- unitcost
My aim is to get a list of all suppliers (including suppliers with no orders) showing the total value of orders raised against each one (zero for suppliers with no orders).
Unfortunately, the OrderDetail table holds order lines but doesn't hold a line value, just quantity and unit price for each line on an order.
So, I assume I need to multiply 'orderqty' by 'unitcost' for each line in the OrderDetail table then sum the result by supplier and join that to the Supplier table using 'suppliernum' to display the supplier name.
Could someone let me know if I'm looking at this the right way and maybe suggest an SQL example?