2
I have the following appointment:
SELECT
fm.FIELDCODE,
fm.BLOCK_CODE,
bl.BLOCK_DESC,
cat.CATEGORY_CODE,
cat.CATEGORY_ABBREV,
fm.FIELD_AREA,
fm.PLANTATION_DATE,
fm.HARVEST_END_DATE
FROM
FM_BLOCK bl,
FM_FIELD_CATEGORY cat,
FM_FIELDMASTER_DETAIL fm
WHERE
fm.PLANTATION_DATE = (
SELECT MAX(fm.PLANTATION_DATE)
FROM FM_FIELDMASTER_DETAIL fm where fm.FIELDCODE = '102'
)
and fm.BLOCK_CODE = bl.BLOCK_CODE
and fm.DPTCOD = bl.DPTCOD
and fm.CATEGORY_CODE = cat.CATEGORY_CODE
and fm.FIELDCODE = '102'
How do I consult to return the FIELDCODE
with PLANTATION_DATE
most recent case by column HARVEST_END DATE
no value if the column HARVEST_END_DATE
have record return me FIELDCODE
with HARVEST_END_DATE
more recent as I do, any suggestions??? because my consultation only brings me the FIELDCODE
with PLANTATION_DATE
most recent.
PLANTATION_DATE or HARVEST_END DATE : @Kennel Rafael ?
– Motta
Friend, which bank is the query? And you have how to simplify your doubt? Ta very confusing..
– Andrey
Have you looked at how the
case when
?– Ricardo Pontual
Yes ja, now it works with Code
– JosefoSad