17,140
社区成员




select max(time),id from table2 where id in(
select id from table1 where name like '%北京%' and (
name like '%北京-出库%' or name like '%北京-出库%') ) group by id
SELECT t1.ID, t1.NAME, t2.TIME, t2.DATA
FROM table1 t1,
(SELECT ID, TIME, DATA
FROM (SELECT ID, TIME, DATA,
ROW_NUMBER () OVER (PARTITION BY ID ORDER BY TIME DESC)
rn
FROM table2)
WHERE rn = 1) t2
WHERE t2.ID = t1.ID AND t1.NAME LIKE '北京%'
select *
from table2,
table1
where table2.id = table1.id
and table1.name like '%北京%'
and (table2.id,table2.time) in (select id,max(time) from table2 group by id);