My SQL skills are rusty and despite Googling I can't quite figure out this one. I'll be thankful for any help.
I have an orders table, with typical order-related fields: order # (which is the primary key), purchase order #, etc.
Basically, what I'm trying to achieve is this: find duplicate PO numbers, and list the order numbers to wich they are related. The output should be something akin to this:
PO # | ORDERS
-----------------
1234 | qwerty, abc
-----------------
1235 | xyz, def
So far I've come up with a query that finds duplicate PO numbers and their occurrences, but I can't figure out the orders list part.
SELECT PO,COUNT(PO) AS OCCURRENCES
FROM ORDERS
GROUP BY PO
HAVING COUNT(PO) > 1
BTW, this is Oracle, if it makes any difference (something I'm new to, in addition to my rusty skills, argh!). Thanks for the help!