ClickHouse/tests/queries/0_stateless/00524_time_intervals_months_underflow.sql
sperlingxx a901faeb84 Fix add/minus Date Interval over Date32 type
Signed-off-by: sperlingxx <lovedreamf@gmail.com>
2022-10-13 18:00:54 +08:00

71 lines
3.8 KiB
SQL

SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 0 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 1 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 11 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 12 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 13 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -1 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -11 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -12 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -13 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 0 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 1 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 11 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 12 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 13 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -1 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -11 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -12 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -13 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 0 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 1 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 11 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 12 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 13 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL -1 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL -11 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL -12 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL -13 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 0 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 1 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 11 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 12 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 13 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL -1 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL -11 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL -12 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL -13 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 0 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 1 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -1 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 0 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 1 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -1 YEAR AS x;
SELECT toDate('2017-01-01') + INTERVAL 0 YEAR AS x;
SELECT toDate('2017-01-01') + INTERVAL 1 YEAR AS x;
SELECT toDate('2017-01-01') + INTERVAL -1 YEAR AS x;
SELECT toDate('2017-01-01') - INTERVAL 0 YEAR AS x;
SELECT toDate('2017-01-01') - INTERVAL 1 YEAR AS x;
SELECT toDate('2017-01-01') - INTERVAL -1 YEAR AS x;
SELECT INTERVAL number - 15 MONTH + toDate('2017-01-01') AS x FROM system.numbers LIMIT 30;
SELECT toDate('2017-01-01') - INTERVAL number - 15 MONTH AS x FROM system.numbers LIMIT 30;
SELECT INTERVAL number - 15 YEAR + toDate('2017-01-01') AS x FROM system.numbers LIMIT 30;
SELECT toDate('2017-01-01') - INTERVAL number - 15 YEAR AS x FROM system.numbers LIMIT 30;
SELECT toDate32('2217-01-01') + INTERVAL number * 20 - 100 DAY AS x FROM system.numbers LIMIT 10;
SELECT INTERVAL 100 - number * 20 DAY + toDate32('2217-01-01') AS x FROM system.numbers LIMIT 10;
SELECT INTERVAL number * 4 - 20 MONTH + toDate32('2217-01-01') AS x FROM system.numbers LIMIT 10;
SELECT toDate32('2217-01-01') - INTERVAL number * 4 - 20 MONTH AS x FROM system.numbers LIMIT 10;
SELECT INTERVAL number * 4 - 20 YEAR + toDate32('2217-01-01') AS x FROM system.numbers LIMIT 10;
SELECT toDate32('2217-01-01') - INTERVAL number * 4 - 20 YEAR AS x FROM system.numbers LIMIT 10;