没事刷到了,上午刷都刷了,整理一下吧

lc1873

# Write your MySQL query statement below
SELECT 
    employee_id,
    CASE 
        WHEN employee_id % 2 = 1 AND name NOT LIKE 'M%' THEN salary
        ELSE 0
    END AS bonus
FROM Employees
ORDER BY employee_id;

 

lc619

# Write your MySQL query statement below
SELECT 
    MAX(num) AS num
FROM (
    SELECT num
    FROM MyNumbers
    GROUP BY num
    HAVING COUNT(*) = 1
) AS single_numbers;

 

lc1148

# Write your MySQL query statement below
select 
    author_id as 'id'
from 
    Views
where 
    Views.author_id = Views.viewer_id
group by 
    author_id
order by 
    author_id

 

lc183

# Write your MySQL query statement below
select Customers.name as 'Customers'
from Customers 
where Customers.id not in (
    select Orders.customerId 
    from Orders 
)

 

lc196

# Write your MySQL query statement below
DELETE p1       #只删除表p1
FROM Person AS p1
    INNER JOIN Person AS p2
WHERE p1.Email = p2.Email
    AND p1.Id > p2.Id

 

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐