I need to compare column user_id with another column order_id in the same table Orders.
If a user_id has multiple distinct order_id's, then I need to default order_id to '00000'. If user_id has two same order_id's, then that user_id should have only one entry.
Input table: Orders
| user_id | order_id |
|---|---|
| A234 | 87655 |
| A234 | 89765 |
| A234 | 98723 |
| R678 | 09874 |
| R678 | 09874 |
Expected output:
| user_id | order_id |
|---|---|
| A234 | 00000 |
| R678 | 09874 |
GROUP BY user_idandHAVING COUNT(*) > 1