在Oracle中进行查询排序时,如果排序字段里面有空值的情况下,排序结果可能会达不到自己想要的结果. 如 select * from tableTest order by VISITS desc 上图可以看到表示服务访问次数的“VISITS”字段上的空值记录排序时放在前面,和实际逻辑不对 将原来的sql语句改写为:select * from tableTest order by VISITS desc nulls last, "nulls last"控制将空值记录放在后…
转载于:https://www.cnblogs.com/contixue/p/7057025.html Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the…
表结构: create table user ( id int primary key, name varchar(), sex varchar(), index(name) )engine=innodb; insert into user values(, 'shenjian','no'); insert into user values(, 'zhangsan','no'); insert into user values(, 'lisi', 'yes'); insert into user…