PostgreSQL 拼接后,去重再给查询列表增加序号
select ROW_NUMBER() over(ORDER bY numberPlate ) AS num,ROW_NUMBER() over(ORDER bY numberPlate asc ) AS key,numberPlate from
(select DISTINCT concat_ws('','[',concat_ws(']',(select bus_code from san_vehicle where id = sps.real_vehicle_id),(select number_plate from san_vehicle where id = sps.real_vehicle_id)) ) numberPlate from san_plan_task sps
inner join san_vehicle se on sps.real_vehicle_id=se.id
where 1=1 and sps.plan_date= '2021-08-24') r
效果入下图