I have a table1, and table2. There are sevaral rows in table2 for ID from table1. Example: Table1 (ID, Name, Age):
543 | John | 15
321 | Doe | 17.
SELECT SCORE
FROM TABLE2
WHERE ID = 543
(many rows as response).
I need a query with some columns from table1, as well as first row in column from table2.
Something like that:
SELECT A.NAME NAME,
A.AGE AGE,
(SELECT SCORE
FROM TABLE2 B
WHERE A.ID = B.ID
AND ROWNUM = 1) SCORE
FROM TABLE1 A,
TABLE2 B
WHERE A.ID = B.ID
ROWNUM = 1could theoretically give you any of the correlated rows fromTABLE2.