Ⅰ 数据库期末考试题 编写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 课程号;