谁能帮帮忙,如何写出满足以下条件的SQL语句,不甚感激!

[复制链接]
查看11 | 回复2 | 2008-8-17 16:12:36 | 显示全部楼层 |阅读模式
表名为class
1.返回字段 c_name,c_stu
2.返回记录数:前5条
3.查询条件:c_stu值大于30,并且c_type值为真,并且c_name字段值中有“好”字
4.查询结果按c_stu正排序,按c_type倒排序(正排序不要省略排序关键字)

回复

使用道具 举报

千问 | 2008-8-17 16:12:36 | 显示全部楼层
select top 5 c_name,c_stu from classwhere c_stu> 30 and c_type = '真' and c_name like '%好%'order by c_stu asc,c_type desc;但是我觉得同时用两种排序得出来的效果不理想
回复

使用道具 举报

千问 | 2008-8-17 16:12:36 | 显示全部楼层
select top 5 * from class where c_stu > 30 and c_type = '真' and c_name like '%好%' order by c_stu asc,c_type desc
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行