I need to select only row 1 from the table, I already used DISTINCT
and it did not work
Follow Query:
select
Max(remessa.dt_uso_inicio) as DATA_REMESSA
,min(dt_entorc_oficina)DATA_ABERTURA
,patr.nr_patrimonio AS PATRIMONIO
from
orcos as o
join
patrimon as patr
on o.cd_PATRIMONIO= patr.cd_PATRIMONIO
join
v_remessa_patrimonio as remessa
on remessa.cd_patrimonio = patr.cd_patrimonio
where patr.nr_patrimonio = '070-13 GEA'
group by
patr.nr_patrimonio
,o.dt_entorc_oficina
having o.dt_entorc_oficina > max(remessa.dt_uso_inicio)
;
Continuetopic: Select the line with the oldest date within that query between repeated values