表中数据是集合,集合是没有顺序的。order by返回的数据是有顺序的,故此我们把order by以后返回的数据集合叫“游标”。
--------------------------通过order by 语句进行排序 --1.降序order by 列名 desc --2.升序order by 列名 或者 order by 列名 asc --3.order by 语句必须一定要放在整个sql语句的最后 select * from biao inner join ... where ... group by ... having ... order by ... --4.根据多列进行排序 --先根据英语成绩排序,再根据数学成绩排序(先按照英语成绩排序,如果英语成绩相同,再按照数学成绩排序) select * --3 from TblScore --1 where tenglish>=60 and tmath>=60 --2 order by tenglish desc,tmath desc --4 --5.可以按照表达式进行排序 select *, 平均分=(tenglish+tmath)*1.0/2 from TblScore order by 平均分 desc --或者 order by (tenglish+tmath)*1.0/2 desc