哇塞,在找關(guān)于趙強(qiáng)老師今晚在課堂上提出來(lái)的關(guān)于Oracle表自連接的缺點(diǎn)及解決方法時(shí),碰巧就找到趙強(qiáng)老師本人解答的視頻了。厲害厲害,講的依舊清晰明了!明白了。贊!
2018-04-20
select deptno ,avg(sal)
from emp
group by deptno
having ave(sal) > 2000
from emp
group by deptno
having ave(sal) > 2000
2018-04-19
select deptno ,avg(sal)
from emp
group by deptno ; --按照部門編號(hào)分組
select a,b,c ,組函數(shù)(x)
from table
group by a ; --這里應(yīng)該寫(xiě)a,b,c 不能只寫(xiě)a 通過(guò)部門號(hào) 然后通過(guò)b c條件接著分組
只寫(xiě)a ora-00937 非法使用分組函數(shù)
在select 列表中所有未包含的組函數(shù)中的列 group by中都應(yīng)該寫(xiě)
select avg(sal)
from emp
group by deptno; --這種不會(huì)展示deptno
from emp
group by deptno ; --按照部門編號(hào)分組
select a,b,c ,組函數(shù)(x)
from table
group by a ; --這里應(yīng)該寫(xiě)a,b,c 不能只寫(xiě)a 通過(guò)部門號(hào) 然后通過(guò)b c條件接著分組
只寫(xiě)a ora-00937 非法使用分組函數(shù)
在select 列表中所有未包含的組函數(shù)中的列 group by中都應(yīng)該寫(xiě)
select avg(sal)
from emp
group by deptno; --這種不會(huì)展示deptno
2018-04-19
select sum(sal)/count(*) , sum(sal)/count(sal) , avg(sal) from emp ;
count(*) 會(huì)包含空值的個(gè)數(shù)
分組函數(shù)會(huì)自動(dòng)過(guò)濾掉空值
nvl函數(shù) 使得分組函數(shù)不忽略空值
nvl(comm,0) 這個(gè)函數(shù)的意思是 當(dāng)該字段為空的時(shí)候返回第二個(gè)參數(shù)
當(dāng)字段不為空 返回他本身
這個(gè)函數(shù)可用于自增的輸入
nvl(max(sno),0))+1 最大值加一 可用于插入數(shù)據(jù)的編號(hào)
count(*) 會(huì)包含空值的個(gè)數(shù)
分組函數(shù)會(huì)自動(dòng)過(guò)濾掉空值
nvl函數(shù) 使得分組函數(shù)不忽略空值
nvl(comm,0) 這個(gè)函數(shù)的意思是 當(dāng)該字段為空的時(shí)候返回第二個(gè)參數(shù)
當(dāng)字段不為空 返回他本身
這個(gè)函數(shù)可用于自增的輸入
nvl(max(sno),0))+1 最大值加一 可用于插入數(shù)據(jù)的編號(hào)
2018-04-19
select avg (表中列字段) ,sum (表中列字段) from 表; --列出 表中字段的平均值,和
select max (表中的字段), min (表中的字段) from 表 ; --列出表中字段的 最大值 最小值
select count(*) from 表; 輸出這個(gè)表中一共有的數(shù)據(jù)條數(shù)
select count(distinct 表中字段) from 表; 輸出表中不重復(fù)字段的個(gè)數(shù)
distinct 用于去重
select max (表中的字段), min (表中的字段) from 表 ; --列出表中字段的 最大值 最小值
select count(*) from 表; 輸出這個(gè)表中一共有的數(shù)據(jù)條數(shù)
select count(distinct 表中字段) from 表; 輸出表中不重復(fù)字段的個(gè)數(shù)
distinct 用于去重
2018-04-19
最新回答 / 寒山問(wèn)道
select sum(sal) from emp where deptno=10;select avg(sal) from emp where deptno = 10;試一試估計(jì)你Sql寫(xiě)錯(cuò)了吧
2018-04-17
select
pm_ci.ci_id as ci_id
, listagg(to_char(pm_stu.stu_name), ',') within group(order by pm_stu.stu_id) as stu_name
from
pm_ci
inner join pm_stu
on substr(pm_ci.stu_id, instr(pm_ci.stu_id, pm_stu.stu_id),1) = pm_stu.stu_id
group by pm_ci.ci_id;
pm_ci.ci_id as ci_id
, listagg(to_char(pm_stu.stu_name), ',') within group(order by pm_stu.stu_id) as stu_name
from
pm_ci
inner join pm_stu
on substr(pm_ci.stu_id, instr(pm_ci.stu_id, pm_stu.stu_id),1) = pm_stu.stu_id
group by pm_ci.ci_id;
2018-04-15
select
pm_ci.ci_id as ci_id
, listagg(to_char(pm_stu.stu_name), ',') within group(order by pm_stu.stu_id) as stu_name
from
pm_ci
inner join pm_stu
on instr(pm_ci.stu_id, pm_stu.stu_id) > 0
group by pm_ci.ci_id;
pm_ci.ci_id as ci_id
, listagg(to_char(pm_stu.stu_name), ',') within group(order by pm_stu.stu_id) as stu_name
from
pm_ci
inner join pm_stu
on instr(pm_ci.stu_id, pm_stu.stu_id) > 0
group by pm_ci.ci_id;
2018-04-15
最新回答 / 慕田峪9362115
sql標(biāo)準(zhǔn)格式 ?select * from 表 ?1表全用的子查詢查出了結(jié)果 ,最后不需要from表了,就必須用偽表dual來(lái)滿足格式需要了
2018-04-05