row_number () over () packet partition by sorting for the result set to the packet

select * from (
        select   row_number() over(partition by Gid order by Gid ASC) as RowN, *
        from(
        select b.Gid, a.OrderNo,b.Carcode from  fit_CarOrder a inner join  Fit_CarDetail b
        on a.OrderNo=b.DetailNo
        inner join  Fit_OrderDetail  c on a.Gid=c.OrderGid
        where a.orderno='201909180000038000099988'
        ) as bb)
        as tt  where  tt.RowN=1

When the main unit corresponding to packet ordering for sorting a plurality of packets to the detail corresponding to the detail weight if the third master unit there are also detailed information corresponding to the best depends on the details of the second table to sort ID packet filter duplicates

Guess you like

Origin www.cnblogs.com/Warmsunshine/p/11549787.html