Subject Re: [firebird-support] Calling a SP without modify the 'from ***' statement
Author PenWin
> hi all, i have this 2 table (there i simplify them)
>
> Users
> {
> integer ID
> }
>
> Documents
> {
> integer ID,
> integer USER_ID //it's a FK
> timestamp CREATION_TIME
> }
>
> now i have this query
>
> select u.ID from Users u
>
> i need to modify that to have also the last document but i can change only the select statement, not the from ***,
>
SELECT u.ID, (SELECT FIRST 1 d.ID FROM Documents d WHERE d.USER_ID=u.ID
ORDER BY d.CREATION_TIME DESC) LAST_DOCUMENT_ID FROM Users u