一、根据barcode去重,每个barcode都取最近更新的一条
SELECT DISTINCT ON (barcode) *
FROM your_schema1.your_table1
ORDER BY barcode, updated_time DESC;
二、有where条件时也可以这么写
SELECT DISTINCT ON (barcode) *
FROM your_schema1.your_table1
where barcode in (select barcode from your_schema2.your_table2 where updated_by = 'dalao')
and updated_by != 'dalao'
ORDER BY barcode, updated_time DESC;