join连表后,查询多条数据后,分组后取一条数据``````
select * FROM ep61 a
join ep62 b
on a.aaz635 = b.aaz635
where 1 = 1
and b.aae601 in ('1', '0')
and a.aae596 <> '0'
and b.aae599 = '4028c69b6dafde16016db36937350012'
查出结果:
--修改后的sql:
select ep.aae601
from (select a.*,
b.*,
row_number() over(partition by a.aaz635 order by b.aaz636 desc ) sdafsda
FROM ep61 a
join ep62 b
on a.aaz635 = b.aaz635
where 1 = 1
and b.aae601 in ('1', '0')
and a.aae596 <> '0'
and b.aae599 = '4028c69b6dafde16016db36937350012') ep where ep.sdafsda = 1