Say I have the following Person table:
ID, Name, Age, Height, Weight
I do the following query:
SELECT * FROM Person WHERE name = 'Fred' AND age = '19' AND ROWNUM <= 1
This will return the 1st row that matches those criteria.
Now I do the following query:
SELECT * FROM Person WHERE name || '|' age IN ('Fred|19','Joe|25','Sam|21')
This will return all rows that match the criteria.
My question is is there a way to combine the "rownum" functionality of the 1st query with the multi criteria of the 2nd query. I want to get the 1st result of Fred|19 (if any), 1st result of Joe|25 (if any) and 1st result of Sam|21 (if any)
Simply combining these won't work:
SELECT * FROM Person WHERE name || '|' age IN ('Fred|19','Joe|25','Sam|21') AND ROWNUM <= 3
If there are 3+ rows with Fred|19, I will get those 3 rows back. I'm using Oracle database if that helps