0

昇順の一連の日付で欠落しているすべての日付を取得しようとしています。関数やudfsを使用せずに単純なSQLを使用してそれを行うにはどうすればよいですか。

Input :-

2016-09-01
2016-09-02
2016-09-05
2016-09-10

出力:-

2016-09-03
2016-09-04
2016-09-06
2016-09-07
2016-09-08
2016-09-09

私が試したことは何ですか?

  select start, stop 
    from
       (
          select m.x + 1 as start,
                 (select min(x) - 1 from X as x where x.x > m.x) as stop
            from X as m
           left outer join X as r
              on m.x = r.x - 1
           where r.x is null
        ) as x
  where stop is not null;
4

1 に答える 1