如何在 SQL 查询中同时 select 分隔时间间隔?
How can I select separate time intervals simultaneously in SQL query?
下面是我的 SQL 查询的一部分。我想要 select 所示时间段的数据。我有许多特定的日期范围需要包含在 'or' 语句中。我怎样才能更改我的查询以使其按预期工作。
where and a1.TS between (('01-MAR-18 06:40:00.0' and '02-MAR-18 06:40:00.0') or ('04-MAR-18 06:40:00.0' and '05-MAR-18 06:40:00.0'))
and a1.name = 'WV3_NDC_Avg123_Moistur'
and a2.name = 'WV3_SAWDI_NO'
and a3.name = 'WV3_PRODUCT'
and a4.name = 'WV3_CI_FO_NO_CHUTES'
and a5.name = 'WV3_VS_DFWL_COL_B'
and a6.name = 'WV3_FOM_ONSTS'
and a8.name = 'WV3_OVM_ONSTS'
and a9.name = 'WV3_PI_OV_RAMP_HGHT_SF'
and a10.name = 'WV3_PULLCAM_TOT_MINMONTH'
and a11.name = 'WV3_VS_BAT_HGT_AVG'
and a12.name = 'WV3_LD_BOVEN_S'
and a13.name = 'WV2_THEO_LSPD_ADJ'
此查询是用 Aspen SQLPlus 编写的,正在访问历史数据库。为了使查询正常工作,我创建了一个临时 table,并查询 table。我不知道这是否有所作为,但值得注意。
此外,
where a1.TS between '01-MAR-18 06:40:00.0' and '02-MAR-18 06:40:00.0'
工作正常。
您需要重复列名:
where ( (a1.TS between '01-MAR-18 06:40:00.0' and '02-MAR-18 06:40:00.0') or
(a1.TS between '04-MAR-18 06:40:00.0' and '05-MAR-18 06:40:00.0')
) and
. . .
下面是我的 SQL 查询的一部分。我想要 select 所示时间段的数据。我有许多特定的日期范围需要包含在 'or' 语句中。我怎样才能更改我的查询以使其按预期工作。
where and a1.TS between (('01-MAR-18 06:40:00.0' and '02-MAR-18 06:40:00.0') or ('04-MAR-18 06:40:00.0' and '05-MAR-18 06:40:00.0'))
and a1.name = 'WV3_NDC_Avg123_Moistur'
and a2.name = 'WV3_SAWDI_NO'
and a3.name = 'WV3_PRODUCT'
and a4.name = 'WV3_CI_FO_NO_CHUTES'
and a5.name = 'WV3_VS_DFWL_COL_B'
and a6.name = 'WV3_FOM_ONSTS'
and a8.name = 'WV3_OVM_ONSTS'
and a9.name = 'WV3_PI_OV_RAMP_HGHT_SF'
and a10.name = 'WV3_PULLCAM_TOT_MINMONTH'
and a11.name = 'WV3_VS_BAT_HGT_AVG'
and a12.name = 'WV3_LD_BOVEN_S'
and a13.name = 'WV2_THEO_LSPD_ADJ'
此查询是用 Aspen SQLPlus 编写的,正在访问历史数据库。为了使查询正常工作,我创建了一个临时 table,并查询 table。我不知道这是否有所作为,但值得注意。
此外,
where a1.TS between '01-MAR-18 06:40:00.0' and '02-MAR-18 06:40:00.0'
工作正常。
您需要重复列名:
where ( (a1.TS between '01-MAR-18 06:40:00.0' and '02-MAR-18 06:40:00.0') or
(a1.TS between '04-MAR-18 06:40:00.0' and '05-MAR-18 06:40:00.0')
) and
. . .