Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

selezionando la colonna superiore1 con la colonna2 corrispondente

solo andata

select t1.* from
(select id,max(pid) as Maxpid
from yourtable
group by id) t2
join yourtable t1 on t2.id = t1.id
and t2.Maxpid = t1.pid