贴吧用户_0eb7UW6 乐尤儿木咖
嗯,写什么呢??
关注数: 102 粉丝数: 79 发帖数: 3,157 关注贴吧数: 79
数据库 1.查询已授课程的课程号,要求显示的课程号不重复。(消除取值重复的行) selectdistinct Cno from授课表; 2. 查询全体老师的姓名及其年龄,查询结果的列名为姓名、年龄。(提示:使用系统函数getdate()获取当前日期,使用系统函数year()获取日期中的年份)(目标列表达式、列别名) select Tname 姓名,(year(getdate())-year(Birthday))年龄 from教师表; 3. 查询全体教师的姓名及其年龄,并按教师的年龄降序排列。(排序) select Tname 姓名,(year(getdate())-year(Birthday))年龄 from教师表 orderby年龄; 4. 检索名字中第二个字是“力”或“历”的教师的详细信息。(通配符) select* from教师表 where Tname like('_历%')or Tname like('_力%'); 5. 查询未录入出生日期的教师姓名。(空值) select Tname from教师表 where Birthday isNULL; 6. 查询教师总人数。(聚集函数) selectcount(distinct Tno)people from教师表; 7. 汇总各位授课教师的教师号及总学时。(分组统计) select Tno,sum(Hours)总学时 from授课表 groupby Tno; 8. 统计每个部门男女教师的人数。(分组统计) select Dept 部门,Tsex 性别,count(Dept)人数 from教师表 groupby Tsex,Dept; 9. 计算所教授的每门课程均在40学时以上的教师的教师号和平均学时。(分组筛选) select Tno,avg(Hours)平均学时 from授课表 groupby Tno havingmin(Hours)>40 10. 统计女教师各个年龄的人数,求出超过1人的年龄和该年龄的人数。(条件筛选、分组筛选) selectyear(getdate())-year(Birthday)年龄,count(year(getdate())-year(Birthday)) amount from教师表 where Tsex='女' groupbyyear(getdate())-year(Birthday) havingcount(year(getdate())-year(Birthday))>=1 1. 查询教授“英语”课的教师的姓名。(嵌套或连接) select Tname from 教师表 where Tno in (select Tno from 授课表 where Cno in (select Cno from 课程表 where Cname=’英语’ ) ); 2. 查询教授”0001”课程比”0002”课程学时高的所有教师的教师号。(嵌套) select T1.Tno from 授课表 T1,授课表 T2 where T1.Tno=T2.Tno and T1.Cno =0001 and T2.Cno =0002 and T1.Hours>T2.Hours; 3. 查询教师的教师号、平均授课学时及根据平均授课学时排的名次。(嵌套) 4. 查询教授过所有课程的教师的教师号。(EXISTS谓词) 5. 查询至少教授了“2004003”号教师教授的全部课程的教师的教师号。(EXISTS谓词) 6. 查询既上“英语”课又上“经济学”课的教师的教师号。(集合) 7. select Tno from 课程表,授课表 where 课程表.Cno = 授课表.Cno and Cname='英语' intersect select Tno from 课程表,授课表 where 课程表.Cno = 授课表.Cno and Cname='经济学' 7. 在教师表中插入2条记录,分别是张元、李光,其余属性值自拟。(添加) 8. 删除教师“刘元”的教师信息。(删除) 9. 将计算机系的系名改为计算机科学系。(更新) update 教师表 set Dept='大计基'
1 下一页