濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > sql 語(yǔ)句練習(xí)與答案

sql 語(yǔ)句練習(xí)與答案

熱門(mén)標(biāo)簽:承德地圖標(biāo)注公司名需要花錢(qián)嗎 慶陽(yáng)地圖標(biāo)注 浙江穩(wěn)定外呼系統(tǒng)供應(yīng)商 怎么給高德做地圖標(biāo)注 北京400電話辦理多少錢(qián) 咸陽(yáng)電腦外呼系統(tǒng)運(yùn)營(yíng)商 美團(tuán)地圖標(biāo)注商戶(hù)認(rèn)證注冊(cè) 榕城市地圖標(biāo)注 電銷(xiāo)外呼系統(tǒng)軟件功能
1學(xué)生表student

S#學(xué)號(hào),sname姓名,difdate日期,班級(jí)grade

2課程表 course

c#課程號(hào) ,名字cname

3成績(jī)單score

s#學(xué)號(hào) c#課程號(hào) 成績(jī)score


--1統(tǒng)計(jì)每個(gè)班級(jí)有多少人
select grade,count(sname) from ze_student group by grade;

--2、2007級(jí)的各學(xué)生的平均成績(jī) 沒(méi)有成績(jī)的為0;
select a.sname,(select avg(nvl(b.score,0)) from ze_score b where b.s#=a.s#) from ze_student a where grade=2007;

--3 每科 平均成績(jī)和最高成績(jī) 最低成績(jī) 2007級(jí) 保留2位小數(shù)點(diǎn) 四舍五入
select b.c#,avg(b.score),max(b.score),min(nvl(b.score,0)) from ze_student a,ze_score b where b.s# = a.s# and a.grade =2007 group by b.c#;

--4 給2007級(jí) 數(shù)學(xué)加5分
update ze_score
set score=nvl(score,0)+5
where s# in (select s# from ze_student where grade=2007) and c# =(select c# from ze_course where cname='數(shù)學(xué)');

--5 90分以上的為優(yōu)秀 90到85為良好,60分 不及格 各人平均成績(jī)
select s#, c,
case
when c>=90 then '優(yōu)秀'
when c90 and c>=60 then '及格'
else '不及格' end as jige
from (select s#,avg(nvl(score,0)) as c from ze_score group by s# ) order by jige desc;


--6 求同月出生的 人數(shù)
select to_char(difdate,'mm') as 月份,count(s#) as 出生人數(shù) from ze_student group by to_char(difdate,'mm');

--7 各科的及格率和平均成績(jī) 截取 保留2位
--及格率
select c#,avg(nvl(score,0))as 平均成績(jī),sum(nvl(score,0))as 總成績(jī), count(s#) as 各科人數(shù),
trunc(sum(
case when nvl(score,0)>60 then '1'
else '0' end)/count(s#),2) as 及格率
from ze_score group by c#;

--每人的及格率
select s#, avg(nvl(score,0))as 平均成績(jī),sum(nvl(score,0))as 總成績(jī), count(c#) as 總科目,
sum(
case when nvl(score,0)>60 then 1
else 0 end
)/count(c#) as 及格率
from ze_score group by s#;


--8刪除 姓名是張三 的大學(xué)語(yǔ)文 成績(jī)
select * from ze_score where s# in (select s# from ze_student where sname in '張三') and c#=(select c# from ze_course where cname ='大學(xué)語(yǔ)文');

--9 將數(shù)學(xué)替換成高等數(shù)學(xué)
update ze_course set cname='高等數(shù)學(xué)'where cname like '%數(shù)學(xué)%';

--10 格式化 ,顯示 將學(xué)號(hào)修改成S開(kāi)頭 不足12位補(bǔ)0;
--查詢(xún)
select concat('S',lpad(s#,11,0)) as s# from ze_score ;
select concat('S',lpad(s#,11,0)) as s# from ze_student ;

--格式化
update ze_score set s#= concat('S',lpad(s#,9,0));
update ze_student set s#= concat('S',lpad(s#,9,0));

四個(gè)足球隊(duì)

select a.name,b.name from qiu a,qiu b where a.nameb.name;

commit
rollback
服務(wù)器類(lèi)型
服務(wù)器協(xié)議
全局?jǐn)?shù)據(jù)庫(kù)名稱(chēng)
服務(wù)器IP地址
服務(wù)器端口號(hào)
用戶(hù)名和密碼

標(biāo)簽:呼和浩特 昭通 江蘇 貴州 拉薩 新鄉(xiāng) 重慶 上海

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《sql 語(yǔ)句練習(xí)與答案》,本文關(guān)鍵詞  sql,語(yǔ)句,練習(xí),與,答案,sql,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《sql 語(yǔ)句練習(xí)與答案》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于sql 語(yǔ)句練習(xí)與答案的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    门头沟区| 榆树市| 四平市| 永城市| 庆安县| 自贡市| 治多县| 宝丰县| 中阳县| 平远县| 东乡县| 泰兴市| 海口市| 同江市| 义乌市| 石渠县| 临清市| 昆山市| 西安市| 江孜县| 龙南县| 阿鲁科尔沁旗| 团风县| 博兴县| 随州市| 武穴市| 福鼎市| 翁牛特旗| 宜章县| 亳州市| 赤水市| 临桂县| 吉首市| 嵊州市| 灵璧县| 明星| 彰化县| 中江县| 龙井市| 廊坊市| 交口县|