表t有四个字段a/b/c/d,问下面两个SQL语句结果有什么不同:
select a, b, sum(c) from t where d='t' group by a, b order by a,b
select a, b, sum(c) from t where d='t' group by b,aorder by a,b
区别就是Group By中的列顺序不同。
做了N年SQL了,还从来没有留意这个问题,我直接回答:结果没区别,但是对性能可能有影响
select a, b, sum(c) from t where d='t' group by a, b order by a,b
select a, b, sum(c) from t where d='t' group by b,aorder by a,b