oracle group by语句实例测试
前端之家收集整理的这篇文章主要介绍了
oracle group by语句实例测试,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
sql代码
<div class="codetitle"><a style="CURSOR: pointer" data="77932" class="copybut" id="copybut77932" onclick="doCopy('code77932')"> 代码如下:
<div class="codebody" id="code77932">
CREATE TABLE test(a VARCHAR2( 20),b VARCHAR2 (20),c NUMBER,d VARCHAR2 (20)) INSERT INTO test VALUES( 'a1','b1',1,'t');
INSERT INTO test VALUES( 'a3','b3',3,'t');
INSERT INTO test VALUES( 'a4','b4',4,'t');
INSERT INTO test VALUES( 'a2','b2',2,'t');
INSERT INTO test VALUES( 'xx','xx',5,'x'); INSERT INTO test VALUES( 'a1','x');
COMMIT;
1.SELECT a,b,SUM(c) FROM test WHERE d= 't' GROUP BY a,b ORDER BY a,b; 2.SELECT a,SUM(c) FROM test WHERE d= 't' GROUP BY b,a ORDER BY a,b;