数据库常用面试题
2010-06-23 17:02
295 查看
解答:
--1
select * from students where sid in
(select r_sid from sresult where r_cid=(select cid from Course where cname='税收基础'))
--2
select * from students where sid in
(select r_sid from SResult where r_cid =2)
--3
select * from students where sid not in
(select r_sid from SResult where r_cid =5)
--4
select * from dbo.Students where sid in
(
select r_sid from SResult group by r_sid having count(*) =
(select count(*) from Course)
)
--5
select count(distinct r_sid) from sresult
--select count(*) from
--(select r_sid from sresult
--group by r_sid) a
--6
select * from dbo.Students where sid in
(
select r_sid from SResult group by r_sid having count(*) >5
)
解答:
--1
select * from students where st_id in
(select r_stid from Results where r_tid not in
(select t_id from dbo.Teachers where t_name='李明'))
--2
select a.st_name,b.fenshu from Students a,
(select r_stid,avg(r_fenshi) as fenshu from Results where r_fenshi <60 group by r_stid having count(*) >=2) b
where a.st_id = b.r_stid
--3
select * from Students where st_id in
(
select r_stid from Results where r_tid in
(select t_id from Teachers where t_lesson='数学' or t_lesson='英语')
group by r_stid having count(*) =2
)
--4
select r_stid from Results
where r_fenshi >
(select r_fenshi from dbo.Results where r_tid='t001' and r_stid='st002')
and r_tid ='t001'
--5
--select * from dbo.Students
--select * from dbo.Teachers
select * from (select * from Results where r_tid ='t001') a,(select * from Results where r_tid ='t002') b
where
a.r_stid =b.r_stid
and a.r_fenshi >b.r_fenshi
--select * from Results where (r_tid ='t001' or r_tid ='t002') and r_stid in ('st001','st002','st003') order by r_stid
--select * from Results where r_tid ='t002' order by r_stid
相关文章推荐
- 一道比较常用的数据库的面试题
- 数据库常用面试题(SQL Server) (转载)
- 数据库常用面试题(SQL Server)
- 一道面试题:介绍下常用的数据库
- 数据库常用面试题
- 【转】数据库常用面试题
- 数据库常用面试题(SQL Server) (转载)
- 数据库常用
- 常用的数据库语句:
- 数据库常见笔试面试题
- 【数据库】数据库学习常用文档
- Java中类的加载顺序剖析(常用于面试题)
- IBM 的数据库Informix 常用代语法
- 常用oracle 数据库查询 重要!!
- postgresql数据库常用知识总结
- 数据库常用的操作
- 数据库常用语句
- Android系统自带的常用数据库
- java常用面试题
- 安卓常用数据存储方式之数据库存储