It is necessary in the subquery inside the subquery inside the subquery to be correlated with the field value with the external table. Request such:
select ( select CATEG from (select CATEG from SHIFTS where TABNOM = STATE.TABNOM order by TABNOM, DATEPR desc) where ROWNUM = 1 ) from STATE Here I am trying to get a category (CATEG) from the most recent by date (DATEPR) record for this personnel number (TABNOM) of an employee from the movement table (SHIFTS), for all records from the staffing table (STATE).
But I get the error:
Oracle.DataAccess.Client.OracleException: ORA-00904: "STATE". "TABNOM": invalid identifier
It needs to be done without join-s, only by subqueries, since the entire request is partially formed by an application that cannot be affected.
FETCH FIRST 1 ROWS ONLY. For any version of oracle, it may be convenient to make a function (create function ...) and forget about the subquery altogether, the request itself will end up likeselect getLastCategory(tabnom) from state- Mike