I have a procedure with SELECT
with several JOINS and, in one of them, I need to extract only one result (the most recent date) when several results can really be given. In principle, the dates will never be exact since it is stored in DD/MM/YYYY HH:mm:ss
format and the date field is of type DATE
.
As an example, we would have some questions like the following:
SELECT a,b,c,d,e,f,g,h,i
FROM tabla3 t3
LEFT JOIN Tabla1 t1 ON t1.key = t3.key
LEFT JOIN Tabla2 t2 ON t2.key = t3.key
LEFT JOIN Vista_VW vw ON vw.key = t2.key
-- AND vw.FECHA // (en este JOIN quiero escoger sólo el registro de fecha mayor)
The value of the field FECHA
does not interest me in the SELECT
, I only need to use it as a filter of JOIN
. The date is in the view VW
How to make the JOIN
in the query that returns the record of FECHA
most recent?
As a result I hope to get a pretty large data stack (for the other JOINS
) but this last JOIN
I'm only interested in taking a record and I do not finish clear how to formulate the query SELECT
.