sql语句们

发现leetcode上面也有sql题目,把免费的刷一刷总结下

1. UPDATE CASE...WHEN...

sql语句们_第1张图片
UPDATE salary
SET
    sex = CASE sex
        WHEN 'm' THEN 'f'
        ELSE 'm'
    END;

2. MOD DESC

sql语句们_第2张图片
select *
from cinema
where mod(id, 2) = 1 and description != 'boring'
order by rating DESC
;

3. Group by Having

sql语句们_第3张图片
select Email
from Person
group by Email
having count(Email) > 1;

你可能感兴趣的:(sql语句们)