Why this one can pass only 5/7 ?

  • 0

    select u.pay_date as pay_month, u.department_id, averaged, tt,
    case when averaged > tt then "higher"
    when averaged < tt then "lower"
    else "same" end as comparison
    (SELECT pay_date, department_id, AVG(amount) as averaged from
    (SELECT date_format(s.pay_date, '%Y-%m') as pay_date, e.department_id, s.amount from salary s join employee e
    on s.employee_id=e.employee_id) x
    group by department_id, pay_date order by pay_date DESC, department_id ASC) u,
    (SELECT date_format(pay_date, '%Y-%m') as pay_date, AVG(amount) as tt from salary group by pay_date) i where u.pay_date = i.pay_date

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.