赞
踩
#排序查询 /* order by 排序列表 asc|desc */ #查询学生信息按成绩从低到高排序 SELECT * FROM stuinfo ORDER BY grade ASC; #查询学生信息按成绩从高到低排序 SELECT * FROM stuinfo ORDER BY grade DESC; #按年薪高低显示学生的一年的报酬,还有员工的姓名和年龄。 SELECT NAME AS 姓名, age AS 年龄, reward*12 AS 年薪 FROM stuinfo ORDER BY 年薪 DESC; #按姓名长度从长到短排序 SELECT LENGTH(NAME) AS 长度, NAME AS 名称, age AS 年龄 FROM stuinfo ORDER BY LENGTH(NAME) ASC; #查询学生信息,先按年龄排序,再按成绩排序 SELECT * FROM stuinfo ORDER BY age DESC, grade ASC;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。