有如下数据表:
Table: [student]
ID Name Score
1 chris 100
2 linda 80
3 jack 90
4 andy 80
5 harry 70现在用SELECT语句进行查询:
select * from student where score>70 order by ID asc;
结果如下:
1 chris 100
2 linda 80
3 jack 90
4 andy 80
如果要求有所变化,还要对结果集进行二次排序,以score为索引:
那么语句写成select * from student where score>70 order by ID asc,score asc
如果仍然是
1 chris 100
2 linda 80
3 jack 90
4 andy 80
而我想要的结果是
1 chris 100
3 jack 90
2 linda 80
4 andy 80
请问SQL语句该如何写???
Table: [student]
ID Name Score
1 chris 100
2 linda 80
3 jack 90
4 andy 80
5 harry 70现在用SELECT语句进行查询:
select * from student where score>70 order by ID asc;
结果如下:
1 chris 100
2 linda 80
3 jack 90
4 andy 80
如果要求有所变化,还要对结果集进行二次排序,以score为索引:
那么语句写成select * from student where score>70 order by ID asc,score asc
如果仍然是
1 chris 100
2 linda 80
3 jack 90
4 andy 80
而我想要的结果是
1 chris 100
3 jack 90
2 linda 80
4 andy 80
请问SQL语句该如何写???
解决方案 »
- 求助:两数相加,其一为整数一为小数。为什么结果会是整数。
- mysql里是不是使用了函数,索引就不能用了?
- mysql用max(id) 方法有时查不到最大ID号?内有代码
- 导入数据库错误
- 初学者求教:关于mysql4.1
- 关于mysql中把一个表中中文取出,当再把它们加入另一个表就是乱码的问题?
- 怎样在设置mysql的character_set(win2000下)?linux下为shell ./configure --with-charset=CHARSET
- 求大神帮忙写一条sql语句。
- 这个查询该如何写
- 运行安装接口程序出现以下错误: You have an error in your SQL syntax; check the manual that corr
- DOS下如何在mysql中创建表
- 关于交叉表的问题,并算平均值是怎么写的SQL语句
倒过来后结果集就不一样了,就是说要在已有的结果集上用score作索引进行二次排序,如果数据量很多,颠倒order by子句的列名后会产生完全不同的结果集,这里结果集要保持不变的。