I'm running successfully in my machine, but failed when sumbit sulotion.


  • 0
    W
    SELECT
      id,
      date2 date,
      people
    FROM (
           SELECT
             id,
             people,
             date2,
             @valid := IF(continue_day >= 3 OR (@valid = 1 AND group_id = @last_group_id), 1, 0) valid,
             @last_group_id := t2.group_id
           FROM (
                  SELECT
                    @continue_days := (CASE
                                       WHEN (datediff(date, @last_day) = 1)
                                         THEN (@continue_days + 1)
                                       WHEN (datediff(date, @last_day) < 1)
                                         THEN (@continue_days + 0)
                                       ELSE 1 END)                            continue_day,
                    @last_day := t1.date                                      date2,
                    (@group_id := (@group_id + IF(@continue_days = 1, 1, 0))) group_id,
                    id,
                    people,
                    @valid := TRUE,
                    @last_group_id = ''
                  FROM
                    (SELECT
                       id,
                       people,
                       date,
                       @last_day := '',
                       @group_id := 0,
                       @continue_days := 0
                     FROM stadium
                     WHERE people >= 100) t1) t2
           ORDER BY date2 DESC) t4
    WHERE valid = 1
    ORDER BY date2;
    

    In my machine output:
    5 2017-01-05 145
    6 2017-01-06 1455
    7 2017-01-07 199
    8 2017-01-08 188
    but run here,the anwer:

    {"headers": ["id", "date", "people"], "values": [[7, "2017-01-07", 199], [8, "2017-01-08", 188]]}


Log in to reply
 

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