row_number() over()分組排序功能 partition by 用於給結果集分組

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

分組排序對於主單對應多個明細 分組排序去重  若是 明細中對應到第三個明細中也存在對應的主單信息時 最好取決於第二個表的明細ID來排序分組篩選重複項spa

相關文章
相關標籤/搜索