我有一个表,我想获取其所有名称 工资低于下一个人的人 同一张 table ,我已经尝试过这个但是 它不起作用有什么建议吗?
select t1.Name, t2.Name as Name2
from employees t1
inner join employees t2 on
t1.ID = t2.ID
where t1.Salary < t2.Salary;
我正在尝试打印出每个工资低于下一个的人的姓名
Joe "has less then" Bob
Joe "has less then" foo
Joe "has less then" Bar
Joe "has less then" Pete
最佳答案
比较当前和下一个 ID 列
select t1.Name, t2.Name as Name2 ,t1.salary,t2.salary
from employees t1
inner join employees t2 on
t1.ID+1 = t2.Id
where t1.Salary < t2.Salary;
关于php - 比较同一个表中的两个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36009746/