SQL-取连续日期或者数值

从LVV_START_TIMEKEY开始,取LVV_END_TIMEKEY - LVV_START_TIMEKEY + 1个连续的日期:

SELECT
	TO_DATE (:LVV_START_TIMEKEY,
	'YYYYMMDD') + ROWNUM-1 AS wwm
FROM
	DUAL
CONNECT BY
	ROWNUM <= LAST_DAY (TO_DATE (:LVV_END_TIMEKEY,
	'YYYYMMDD')) - TO_DATE (:LVV_START_TIMEKEY,
	'YYYYMMDD') + 1

同样的,数值也可以,从LVV_START_VALUE开始,取LVV_END_VALUE - LVV_START_VALUE + 1个连续值:

SELECT
	:LVV_START_VALUE + ROWNUM-1 AS wwm
FROM
	DUAL
CONNECT BY
	ROWNUM <= :LVV_END_VALUE - :LVV_START_VALUE + 1

你可能感兴趣的:(SQL,sql,数据库)