I’m having trouble formulating a SQL statement to return the values I want. I need to select data based on user ID, a second column’s value, and a third columns value where the values in that column appear more than once. All columns are within the same table.
Here’s a rough outline of what my query looks like now, but the last AND statement obviously is just to give you an idea of what I want. A COUNT statement that would narrow the results down likely wouldn’t work for me.
SELECT *
FROM table
WHERE user_id = 123
AND second_id = 1
AND third_id having COUNT(1) > 1;
If all you need is the columns user_id, second_id, third_id then try this:
If you have additional columns and want to get those fields as well try this(Oracle 9.2 & above):