select distinct a.PartNumber as 'Part Number', ( select count(1) from Transactions b where b.PartNumber = a.PartNumber) as 'No. Sold' from listings a order by a.PartNumber
It currently takes 30 seconds to run. Transactions has 1200 records and listings has 7000.
Multiple listings can have the same part number, as can transactions. We'd like to know how many transactions there are for each part number, including those part numbers for which there are listings but no transactions. Given the "and zero transactions" requirement, I can't figure out how to do this query with a join.
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org