一、sql-判断三角形
610. 判断三角形 - 力扣(LeetCode)
用一下if加上判断条件
select x,y,z,if(x+y > z and x+z > y and y+z > x
and x-y < z and x-z < y and y-z < x,'Yes','No') as 'triangle'
from Triangle
二、按照分类统计薪水
1907. 按分类统计薪水 - 力扣(LeetCode)
if判断加count 统计+union
select 'Low Salary' as 'category',count(if(income < 20000,1,null)) as 'accounts_count' from Accounts
union
select 'Average Salary' as 'category',count(if(income >= 20000 and income <= 50000,1,null)) as 'accounts_count' from Accounts
union
select 'High Salary' as 'category',count(if(income > 50000,1,null)) as 'accounts_count' from Accounts
三、上级经理已离职的公司员工
1978. 上级经理已离职的公司员工 - 力扣(LeetCode)
子查询没啥好说的
select employee_id
from Employees
where manager_id is not null
and salary < 30000
and manager_id not in (select employee_id from Employees)
order by employee_id asc