哇塞,在找關于趙強老師今晚在課堂上提出來的關于Oracle表自連接的缺點及解決方法時,碰巧就找到趙強老師本人解答的視頻了。厲害厲害,講的依舊清晰明了!明白了。贊!
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 ; --按照部門編號分組
select a,b,c ,組函數(x)
from table
group by a ; --這里應該寫a,b,c 不能只寫a 通過部門號 然后通過b c條件接著分組
只寫a ora-00937 非法使用分組函數
在select 列表中所有未包含的組函數中的列 group by中都應該寫
select avg(sal)
from emp
group by deptno; --這種不會展示deptno
from emp
group by deptno ; --按照部門編號分組
select a,b,c ,組函數(x)
from table
group by a ; --這里應該寫a,b,c 不能只寫a 通過部門號 然后通過b c條件接著分組
只寫a ora-00937 非法使用分組函數
在select 列表中所有未包含的組函數中的列 group by中都應該寫
select avg(sal)
from emp
group by deptno; --這種不會展示deptno
2018-04-19
select sum(sal)/count(*) , sum(sal)/count(sal) , avg(sal) from emp ;
count(*) 會包含空值的個數
分組函數會自動過濾掉空值
nvl函數 使得分組函數不忽略空值
nvl(comm,0) 這個函數的意思是 當該字段為空的時候返回第二個參數
當字段不為空 返回他本身
這個函數可用于自增的輸入
nvl(max(sno),0))+1 最大值加一 可用于插入數據的編號
count(*) 會包含空值的個數
分組函數會自動過濾掉空值
nvl函數 使得分組函數不忽略空值
nvl(comm,0) 這個函數的意思是 當該字段為空的時候返回第二個參數
當字段不為空 返回他本身
這個函數可用于自增的輸入
nvl(max(sno),0))+1 最大值加一 可用于插入數據的編號
2018-04-19
select avg (表中列字段) ,sum (表中列字段) from 表; --列出 表中字段的平均值,和
select max (表中的字段), min (表中的字段) from 表 ; --列出表中字段的 最大值 最小值
select count(*) from 表; 輸出這個表中一共有的數據條數
select count(distinct 表中字段) from 表; 輸出表中不重復字段的個數
distinct 用于去重
select max (表中的字段), min (表中的字段) from 表 ; --列出表中字段的 最大值 最小值
select count(*) from 表; 輸出這個表中一共有的數據條數
select count(distinct 表中字段) from 表; 輸出表中不重復字段的個數
distinct 用于去重
2018-04-19
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;
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;