猫从两米多跳下来:请写出在class表中查找满足如下条件的记录的SQL语句:

来源:百度文库 编辑:高考问答 时间:2024/04/19 08:09:30
1.返回字段 c_name,c_stu

2.返回记录数:前5条

3.查询条件: c_stu值 大于30, 并且 c_type值为真,并且c_name字段值中有"二班"两个字

4.查询结果按c_stu正排序 , 按c_type倒排序 (注:在正排序时请不要省略排序关键字)
请帮我回答....

我用的是Access数据库...

下面的回答都不对....同样也不对..

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

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

Access直接查询:
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倒排序”和“c_type值为真”有些矛盾啊,值都固定了还怎么排序啊?

c_name字段值中有"二班"两个字:不要用'%',应该用'*'
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 ;

我这个绝对没错!
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