當前位置:首頁 » 編程語言 » oracle統計sql

oracle統計sql

發布時間: 2022-08-03 08:34:07

① oracle 關於統計的sql語句,求高人指點!!!

SELECT C_OPERATORS,
SUM(CASE WHEN C_OPERATORS = '移動' THEN 1
WHEN C_OPERATORS = '電信' THEN 1
WHEN C_OPERATORS = '聯通' THEN 1
ELSE 0 END),
TO_CHAR(C_SEND_DATATIME,'YYYYMM')
FROM TABLE_NAME
GROUP BY C_OPERATORS;

② 統計一個欄位的總數量sql語句,oracle資料庫

select
count(*)
from
acc_exchange
where
(工商銀行所在列名)='工商銀行';
你的問題有歧義
INCOME_MONEY這個為列名吧,如果為某列的值,那麼就應該是雙過濾:
select
count(*)
from
acc_exchange
where
(工商銀行所在列名)='工商銀行'
and
(INCOME_MONEY所在列名)='INCOME_MONEY';

③ oracle 統計SQL

--試驗用表
CREATETABLETABLE_DEMO(TIMEDATE,IDVARCHAR2(10),typeVARCHAR2(2),NUMVARCHAR2(10));
--試驗數據
INSERTINTOTABLE_DEMOVALUES(SYSDATE,'01','A','1');
INSERTINTOTABLE_DEMOVALUES(SYSDATE,'0111','A','1');
INSERTINTOTABLE_DEMOVALUES(SYSDATE,'0211','B','1');
INSERTINTOTABLE_DEMOVALUES(SYSDATE,'0221','B','1');
INSERTINTOTABLE_DEMOVALUES(SYSDATE,'0231','C','1');
INSERTINTOTABLE_DEMOVALUES(SYSDATE,'0311','A','1');

--統計的Sql
SELECTR.COUNT_TIME,R.COUNT_ID,R.TYPE,SUM(R.NUM)ASNUM
FROM(SELECTTO_CHAR(T.TIME,'yyyyMMdd')ASCOUNT_TIME,
SUBSTR(T.ID,0,2)ASCOUNT_ID,
T.TYPE,
T.NUM
FROMTABLE_DEMOT)R
GROUPBYR.COUNT_TIME,R.COUNT_ID,R.TYPE
ORDERBYR.COUNT_TIME,R.COUNT_ID,R.TYPE

④ oracle sql怎樣統計數量

可以通過district來取出欄位,之後通過count計算總數量。
sql:select count(district id) from tablename;

如果id欄位沒有空值的話,可以通過count統計欄位的總數量(欄位內容可能重復)。
sql:select count(id) from tablename;

⑤ Oracle數據分類統計的sql語句怎麼寫

好難寫啊,感覺如果要實現你這個效果,可能得改一下表結構吧,反正我只能寫成這樣,你看能可以么。。。
select distinct number,分類,count(a.content) from(select number,a.content,分類 from a,b where a.content=b.content) group by number,分類 order by number,分類;
查出來效果是這樣的
123 養生 1
123 祝福 1
213 幽默 2
213 祝福 1

⑥ oracle 表內做計算再統計的SQL語句怎麼寫 需要算的內容如下

select count(*)
from (select 人員編號,
sum(case
when 變動類型 = '新增' then
1
else
0
end) as 新增次數,
sum(case
when 變動類型 = '刪除' then
1
else
0
end) as 刪除次數
from ceshi
group by 人員編號)
where 新增次數 - 刪除次數 = 1;
select max(時間), 人員編號
from ceshi
where 人員編號 in (select 人員編號
from (select 人員編號,
sum(case
when 變動類型 = '新增' then
1
else
0
end) as 新增次數,
sum(case
when 變動類型 = '刪除' then
1
else
0
end) as 刪除次數
from ceshi
group by 人員編號)
where 新增次數 - 刪除次數 = 1)
group by 人員編號;

⑦ oracle統計查詢 sql語句應該怎麼寫

select
substrb(create_time,1,4)
"年份",
sum(decode(substrb(create_time,6,2),'01',commission,0))
"1月",
sum(decode(substrb(create_time,6,2),'02',commission,0))
"2月",
sum(decode(substrb(create_time,6,2),'03',commission,0))
"3月",
sum(decode(substrb(create_time,6,2),'04',commission,0))
"4月",
sum(decode(substrb(create_time,6,2),'05',commission,0))
"5月",
sum(decode(substrb(create_time,6,2),'06',commission,0))
"6月",
sum(decode(substrb(create_time,6,2),'07',commission,0))
"7月",
sum(decode(substrb(create_time,6,2),'08',commission,0))
"8月",
sum(decode(substrb(create_time,6,2),'09',commission,0))
"9月",
sum(decode(substrb(create_time,6,2),'10',commission,0))
"10月",
sum(decode(substrb(create_time,6,2),'11',commission,0))
"11月",
sum(decode(substrb(create_time,6,2),'12',commission,0))
"12月"
from
test
group
by
substrb(create_time,1,4)
此語句是按create_time欄位是字元型給出的,如果你的表中此欄位是日期型,則進行一下轉化

⑧ oracle sql 某欄位 統計

WITHTTAS
(
SELECT1ASID,15ASCOUNTNUMFROMDUALUNIONALL
SELECT2ASID,12ASCOUNTNUMFROMDUALUNIONALL
SELECT3ASID,11ASCOUNTNUMFROMDUALUNIONALL
SELECT4ASID,16ASCOUNTNUMFROMDUALUNIONALL
SELECT5ASID,8ASCOUNTNUMFROMDUALUNIONALL
SELECT6ASID,20ASCOUNTNUMFROMDUAL
)
SELECTT1.ID,
T1.COUNTNUM,
WM_CONCAT(T2.ID)ASCOUNTNUM,
COUNT(T2.ID)ASGREATNUM
FROMTTT1
LEFTJOINTTT2
ONT1.COUNTNUM<T2.COUNTNUM
GROUPBYT1.ID,T1.COUNTNUM
ORDERBY1

有問題可以追問

⑨ 求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

結果:

熱點內容
怎麼看筆記本配置好壞怎麼對比 發布:2025-01-23 08:50:00 瀏覽:514
安卓q用起來怎麼樣 發布:2025-01-23 08:49:14 瀏覽:294
foreach資料庫 發布:2025-01-23 08:49:05 瀏覽:741
什麼是車棚配置 發布:2025-01-23 08:42:58 瀏覽:312
智能電視盒子無線網密碼在哪裡 發布:2025-01-23 08:42:14 瀏覽:277
代理提取源碼 發布:2025-01-23 08:41:35 瀏覽:62
nas網路伺服器為什麼貴 發布:2025-01-23 08:00:00 瀏覽:941
語音伺服器未連接如何連接視頻 發布:2025-01-23 07:59:11 瀏覽:883
日流量10萬需要什麼類型伺服器 發布:2025-01-23 07:58:27 瀏覽:501
伺服器獲取地址失敗 發布:2025-01-23 07:55:18 瀏覽:850