没什么积分。但确实是一道值得SQL高手挑战的难题?真的 答对你就是天才!

来源:百度知道 编辑:UC知道 时间:2024/09/24 14:19:18
写出CLASS表中查找满足如下条件的记录的SQL语句:
a。返回字段c_name,c_stu

b.返回记录数:前6条
c。查询条件:c_stu值大于20,并且c_type值为假,并且c_name字段值中有“五班”两个字
d。查询结果按c_stu正排序,按c_type倒排序(任何关键字均不可省略)

select top 6 c_name,c_stu from class where c_stu>20 and c_type=0 and c_name like'%五班%' order by c_stu,c_type desc

select top 6 c_name,c_stu from class where c_stu>20 and c_type=false and c_name like '%五班%'
order by c_stu asc,c_type desc

c_type值为假 这个地方不确定我对还是楼上对
order by c_stu asc 楼上把这个关键字省略了
其他好像就没什么异议了

这个天才好容易做!
select top 6 c_name,c_stu from [class] where c_stu>20 and c_type=0 and c_name like'%五班%' order by c_stu,c_type desc