这两个查询的结果有什么不同吗?

时间:2012-09-11 03:01:39

标签: sql sql-server-2008

       Update @A set Column1 = minC     
         from (select Ab.Column2, min(C.Column1) as minC 
        from @A Ab 
        inner join B on Ab.Column2 = B.Column2 
        inner join C on C.column2 = B.Column2 --No need to add again the A.col2 = B.col2
        inner join D on D.column1 = B.column2
        group by Ab.Column2) Grouped where Column2 = Grouped.Column2 

   Update @A set Column1 = minC     
    from (select Ab.Column2, min(C.Column1) as minC, B.column2 as tempcolumn
        from @A Ab 
        inner join B on Ab.Column2 = B.Column2 
        inner join C on C.column2 = B.Column2 --No need to add again the A.col2=B.col2           
        group by Ab.Column2) Grouped 
        inner join D on D.column1 = Grouped.tempcolumn
        where Column2 = Grouped.Column2 

2个查询的结果有什么不同吗?

0 个答案:

没有答案