日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

sql 語句練習(xí)與答案_Mssql數(shù)據(jù)庫教程

編輯Tag賺U幣

推薦:深入C++ string.find()函數(shù)的用法總結(jié)
本篇文章是對(duì)C++中string.find()函數(shù)的用法進(jìn)行了詳細(xì)的總結(jié)與分析,需要的朋友參考下

1學(xué)生表student

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

2課程表 course

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

3成績單score

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


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

--2、2007級(jí)的各學(xué)生的平均成績 沒有成績的為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 每科 平均成績和最高成績 最低成績 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分 不及格 各人平均成績
select s#, c,
case
when c>=90 then '優(yōu)秀'
when c<90 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 各科的及格率和平均成績 截取 保留2位
--及格率
select c#,avg(nvl(score,0))as 平均成績,sum(nvl(score,0))as 總成績, 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 平均成績,sum(nvl(score,0))as 總成績, 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é)語文 成績
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é)語文');

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

--10 格式化 ,顯示 將學(xué)號(hào)修改成S開頭 不足12位補(bǔ)0;
--查詢
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.name<b.name;

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

分享:SQL Server中刪除重復(fù)數(shù)據(jù)的幾個(gè)方法
數(shù)據(jù)庫的使用過程中由于程序方面的問題有時(shí)候會(huì)碰到重復(fù)數(shù)據(jù),重復(fù)數(shù)據(jù)導(dǎo)致了數(shù)據(jù)庫部分設(shè)置不能正確設(shè)置

來源:模板無憂//所屬分類:Mssql數(shù)據(jù)庫教程/更新時(shí)間:2013-06-03
相關(guān)Mssql數(shù)據(jù)庫教程