请问大家这段SQL语句应该怎么写???在线等!

来源:百度知道 编辑:UC知道 时间:2024/05/11 20:04:53
请写出class表中查找满足如下条件的记录的SQL语句:

1、返回字段 c_name,c_stu

2、返回纪录数:前五条

3、查询条件: stu值大于30,并且c_type值为真,并且把c_name字段值中有“二班”两个字

4、查询结果按c_stu正排序,按c_type倒排序(注在正排序时请不要省略排序关键字)

select top 5 c_name,c_stu from 表 where c_stu>30
and c_type=1 and c_name like '%二班%' order by c_stu asc, c_type desc

注意事项,数据类型bit,作为条件可以直接使用1、0来判断。

select top 5 c_name,c_stu from class where c_stu>30
and c_type=true and c_name like '%二班%' order by c_stu asc, c_type desc