oraclesql統計
發布時間: 2025-07-01 01:28:37
Ⅰ 在oracle中用一條sql語句統計a欄位下值為b的數據條數,值為c的數據條數並返回
select 'b',count(a) from 表名 where a='b'
union
select 'c',count(a) from 表名 where a='c';
這樣寫試一下,看看是否好用。
Ⅱ 求Oracle分組統計數量的sql怎麼寫,需求如下
造了點數據,不知道是這個意思不
createtabletest
(totalint,
ssbmvarchar2(20));
insertintotestvalues(5,'02(5)');
insertintotestvalues(5,'02(5)');
insertintotestvalues(5,'04(5)');
insertintotestvalues(5,'04(5)');
insertintotestvalues(5,'03(5)');
commit;
查詢:
selectssbm||'('||cnt||')'from(selectsubstr(ssbm,1,instr(ssbm,'(')-1)ssbm,count(*)cntfromtestgroupbysubstr(ssbm,1,instr(ssbm,'(')-1))t
結果:
熱點內容