Subject | improving select statement |
---|---|
Author | Sergio H. Gonzalez |
Post date | 2010-07-28T14:32:04Z |
Hello!! I just need to select the last occurence of the field "UNITARIO" and
it's ID
This does the job, but I wander if there is a better option.
ID and ID_STOCK has indexes, and the plan reports that they are being used
SELECT
F.UNITARIO, F.ID
FROM
FAC_COM_DETALLE F
WHERE
(F.ID_STOCK=:ID_STOCK)
AND
(F.ID = (select MAX(D.ID) from fac_com_detalle D WHERE D.id_stock =
:ID_STOCK))
THANK YOU !!!
sergio
it's ID
This does the job, but I wander if there is a better option.
ID and ID_STOCK has indexes, and the plan reports that they are being used
SELECT
F.UNITARIO, F.ID
FROM
FAC_COM_DETALLE F
WHERE
(F.ID_STOCK=:ID_STOCK)
AND
(F.ID = (select MAX(D.ID) from fac_com_detalle D WHERE D.id_stock =
:ID_STOCK))
THANK YOU !!!
sergio