select distinct a.query from
(
select query,max(day) as latest_dt from your_table where day >='${dt:format("-1d","yyyy-MM-dd")}'
and 1<length(query) and length(query)<30
group by query
)a
join
(
select query,day from your_table where day >='${dt:format("-1d","yyyy-MM-dd")}'
and tag='0' and 1<length(query) and length(query)<30
)b
on a.latest_dt=b.day
sql 对同一个字段,取数只取最新数据
于 2024-05-16 17:25:45 首次发布