常用语句(四)select top ... ... from ... where ... not in(select top ... ... from ...)、AVG()
2013-04-14 15:44
495 查看
/* alter table score drop constraint FK_student go alter table student drop constraint PK_student go alter table score drop constraint PK_score go */ select top (6-4+1) * from student st1 where st1.sno not in(select top (4-1) st2.sno from student st2) go alter table student add constraint PK_student primary key(sno) go alter table course add constraint PK_course primary key(cno) go alter table score add constraint FK_score1 foreign key(sno) references student(sno) go alter table score add constraint FK_score2 foreign key(cno) references course(cno) go /* */ select sname from student st where st.sno in(select sno from score sc where st.sno=sc.sno and sc.cno=(select cno from course where cname like '%英语%') and grade is not null) go select sname,age from student st inner join score sc on st.sno=sc.sno where cno=(select cno from course where cname like '%英语%') and sc.grade>(select AVG(grade) from score where cno=(select cno from course where cname like '%英语%')) group by sname,age go select AVG(grade) from score where cno=(select cno from course where cname like '%英语%') go /* */
相关文章推荐
- select * from dbo.sysobjects where type not in('S','D','K')
- dedecms Sql标签运行mssql查询 语句 {dede:sql sql='select * from me_flink where typeid=10 limit 0,130 '}
- SQL查询语句中select from where group by having order by的执行顺序
- LINQ To Entities如何实现查询 select * from tableA where id in (1,2,3,4) ?
- C#: from in select ; m(linq where)
- oracle查询语句中select from where group by having order by的解释与应用
- 数据库语句 select * from table where 1=1 的用法和作用
- 数据库语句 select * from table where 1=1 的用法和作用
- SSH报错:org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [select o from User o where 1=1
- 查询语句中select from where group by having order by的执行顺序
- condition = "select * from book where" +field+ "like '%" +keyWord+ "%'"; 这个select where 语句错误?
- 查询语句中select from where group by having order by的执行顺序
- SELECT * FROM p_newsbase where cid in (1,2,6,7,11,) limit 0, 20php100第68讲视频教程(编辑新闻系统)编写代码遇到问题
- sql server 每日一记之 with as delete from where in (select)
- 查询语句中select from where group by having order by的执行顺序
- 数据库语句 select * from table where 1=1 的用法和作用
- 查询语句中select from where group by having order by的执行顺序
- sql Split函数(WHERE RouterID IN (SELECT Item FROM dbo.Split(@routerIds,',')))
- 共享锁select * from t1 where id=2 LOCK IN SHARE MODE;
- 查询语句中select from where group by having order by的执行顺序