【发布时间】:2016-12-14 16:06:41
【问题描述】:
Azure SQL 数据仓库是否支持带有子查询构造的多列 IN/NOT IN?
当运行如下查询时:
select
*
from
schema_name.calendar
where
gregorian_date > '1998-01-01'
and gregorian_date < '1999-01-01'
and (yr_wk, day_of_wk) not in ( select yr_wk, day_of_wk from schema_name.calendar where week = 25 )
;
select
*
from
schema_name.calendar
where
gregorian_date > '1998-01-01'
and gregorian_date < '1999-01-01'
and (yr_wk, day_of_wk) in ( select yr_wk, day_of_wk from schema_name.calendar where week = 25 )
;
收到错误。
SQL Error [103010] [S0001]: Parse error at line: 7, column: 14: Incorrect syntax near ','.
com.microsoft.sqlserver.jdbc.SQLServerException: Parse error at line: 7, column: 14: Incorrect syntax near ','.
是否有将查询重写为具有内部或外部联接的派生表的解决方法?
带有 IN / NOT IN 子查询的单列确实有效:
select
*
from
schema_name.calendar
where
gregorian_date > '1998-01-01'
and gregorian_date < '1999-01-01'
and (yr_wk) not in ( select yr_wk from schema_name.calendar where week = 25 )
;
select
*
from
schema_name.calendar
where
gregorian_date > '1998-01-01'
and gregorian_date < '1999-01-01'
and (yr_wk) in ( select yr_wk from schema_name.calendar where week = 25 )
;
【问题讨论】:
标签: azure-sqldw