Ⅰ 資料庫期末考試題 編寫sql語句 1.創建一張學生表,包含以下信息,學號,姓名,年齡,性別,家庭住址,聯系
create table 學生表
(
學號 char(10) primary key,
姓名 char(10),
年齡 int,
性別 char(2) check (sex IN ('男','女')),
家庭住址 char(40),
聯系 char(20)
)
Ⅱ sql期末考試試題及答案
查詢題:1).select*fromEMPwhereDEPTNO='20';2).select*fromEMPwhereENAMElike'MA%';3).select*fromEMPorderbyJOB;4).selectb.DNAME,COUNT(a.*)asnumfromEMPaleftjoinDEPTbona.DEPTNO=b.DEPTNOgroupbyb.DNAME5).select*fromEMPwhereSAL>(selectmax(SAL)asSALfromEMPwhereDEPTNO='20');程序題:1).函數:CREATEFUNCTION[SumN](@nINT)RETURNSINTASBEGINdeclare@outINT,@iintset@out=0set@i=1while@i<=@nbeginset@out=@out+@iset@i=@i+1endreturn(@out)END2).存儲過程:CREATEPROCEDURE[emp_info](@nDECIMAL(2))ASselect*fromEMPwhereDEPTNO=@n視圖和索引1).CREATEVIEW[emp10_view]ASselect*fromEMPwhereDEPTNO='10'2).ALTERTABLE[EMP]ADDCONSTRAINT[IX_Empno]PRIMARYKEYCLUSTERED([empno]ASC)
Ⅲ SQL期末考試題,來個大神幫解答一下
select fph from mz_brsf
whereje > 200;
2.select sum(je) from mz_brsf
where sfsj >= '2012-01-01'
and sfsj < '2012-02-01';
3.delete from mz_bfsf
where cfh is null;
4.update mz_bfsf
set substr(sfsj,1,4) =2013
where ks ='內科' ;
5. select ks, sum(je) from mz_bfsf
group by ks
having sum(je) >500;
6.select top 2 ys,sum(je)
from mz_bfsf
group by ys
order by sum(je) desc;
7.update a
set a.zc = b.zc
from mz_bfsf a,mz_brxx b
where a.ys = b.ys
Ⅳ 關於求期初數期末數的SQL,該怎麼解決
首先你應該把期初數的計算方法貼出來,
估計你需求的難點應該在累積計算,所以建議把表結構給出來,比較日期的歌手
Ⅳ 在sql查詢中
select 課程號,
avg(期末分數) as 期末平均分,
sum(期中成績+期末成績)
from 成績 where 課程號<>'1002' group by 課程號;