How can I select only those rows which appear in query 1 and not query 2? The goal is to find those reports which have multiple occurrences of the same item.
SELECT finance_report_id, finance_report_item_id FROM finance_report_values;
SELECT DISTINCT finance_report_id, finance_report_item_id FROM finance_report_values;
I was hoping something like the following would work. (This fails because id
isn't selected in the second query.)
SELECT t1.finance_report_id FROM finance_report_values t1
LEFT JOIN (SELECT DISTINCT finance_report_id, finance_report_item_id FROM finance_report_values) t2
ON t1.id = t2.id
WHERE t1.id IS NULL;
I suspect I'm not the first asking this, but I wasn't able to find the same problem posted.