mysql - Table with date, then next date -


i looking generate table 1 date followed next date in set, given criteria.

raw data:

id       date 1     2000-01-01 1     2000-01-02 1     2000-01-04 1     2000-01-10 1     2000-01-14 1     2000-01-15 1     2000-01-16 1     2000-01-18 2     2000-02-01 2     2000-02-02 2     2000-02-04 2     2000-02-10 2     2000-02-14 2     2000-02-15 2     2000-02-16 2     2000-02-18 

would result in:

   id       date           date     1     2000-01-01    2000-01-02     1     2000-01-02    2000-01-04     1     2000-01-04    2000-01-10     1     2000-01-10    2000-01-14     1     2000-01-14    2000-01-15     1     2000-01-15    2000-01-16     1     2000-01-16    2000-01-18     1     2000-01-18    null     2     2000-02-01    2000-02-02     2     2000-02-02    2000-02-04     2     2000-02-04    2000-02-10     2     2000-02-10    2000-02-14     2     2000-02-14    2000-02-15     2     2000-02-15    2000-02-16     2     2000-02-16    2000-02-18     2     2000-02-18    null 

i know have use self join, don't know how return sequentially next largest value, given specific id. thanks.

you use [date + interval 1 day] if mysql or postgresql db

for example:

select t.id, t.date, t.date + interval 1 days date 2 rawdata t; 

for oracle this:

select t.id , t.date, to_date(t.date, 'yyyy-mm-dd') + 1 rawdata t; 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -