SQL Query for sellers who have sold an item more than once

I need help with the next request ... Show the names of sellers who sold us the goods more than once. Indicate the supplier, item and quantity ordered on time. Suppose the seller sold 8 points 240 on December 1 and 12 points 240 on December 30; this counts as two full orders of paragraph 240 (not 20). Tables ...

employee (empid, firstname, middleinitial, lastname, address)
parts (partnum, description)
payments (checknum, checkdate, vendorid, ponum, accountnum, amount)
poitems (ponum, partnum, quantity, unitprice)
purchaseorder (ponum, podate, vendorid, empid, amount)
vendor (vendorid, name, address, phone, tin)
0
source share
1 answer
SELECT vendor.name, partnum, COUNT (DISTINCT ponum) AS times_ordered
FROM purchaseorder
JOIN vendor USING (vendorid)
JOIN poitems USING (ponum)
GROUP BY vendorid, partnum
HAVING times_ordered > 1
+1
source

All Articles