1
I need to create a filter by following the following rule:
- GSM which is repeated, and which
MOTIVO_ENVIO
equal, andSTATUS = 'ANOMALIA TEMPORÁRIA'
import only the line that containsDATA_ALTERACAO
the most recent.
I tried to, but I couldn’t get the DATA_ALTERACAO
(most recent), I even tried to use the MAX
, but it didn’t work out so well, someone could help me?
select ex.gsm,
ex.motivo_envio,
ex.status,
ex.data_ativacao,
ex.data_importacao,
ex.data_alteracao
from export ex
where ex.status = 'ANOMALIA TEMPORÁRIA'
and exists (
select tmp.gsm
from export tmp
where tmp.gsm = ex.gsm
and tmp.motivo_envio = ex.motivo_envio
and tmp.status = ex.status
group by tmp.gsm, tmp.motivo_envio, tmp.status
having count(tmp.gsm) > 1)
Below is an example of what I need, GSM repeating, MOTIVO_ENVIO equal, and STATUS = 'TEMPORARY ANOMALY', I bold and underline the data I want to get, because the DATA_ALTERACAO that GSM is the latest:
Greatly improved its edition in the previous question, but it is important to put the requirements already in one post. Asking a sequence of questions with small differences to develop your work using the features of the site is not our model. Here you already got some more answers, but you’ll really need to take a closer look at the recommended links for better use of the site in the next ones. Follow again: [Tour], [Ask], Manual on how NOT to ask questions and [Help]. - It is the recommendation to always post a [mcve] when applicable.
– Bacco