SQL的基础问题答案

来源:百度知道 编辑:UC知道 时间:2024/06/01 02:47:01
请写出class的满足条件用SQL语句写:
1:返回字段c_came,c_stu
2:返回记录数前5条
3:查询条件:c_stu大于30,并且c_tupe的值为真,并且c_name字段值中有"二班"
4;查询结果按c_stu正排序,按c_type倒排序(注:在正排序时请不要省略排序关键字)

请问大哥 怎么写啊 写了好几个都不对啊!

use databaseName
go
select top 5 c_name,c_stu
from table
where c_stu>30
and c_tupe=true
and c_name in
(select c_name from table where c_name = '二班')
order by c_stu desc, c_type asc;

select top 5 c_came,c_stu
from table
where c_stu>30 and c_tupe=true and c_name in('二班') order by c_stu desc c_type up;

select top 5 c_name,c_stu
from table
where c_stu>30
and c_tupe=true
and c_name in
(select c_name from table where c_name = '二班')
order by c_stu desc, c_type asc;