我有这个我在SQL Server中运行的select语句。但它引发了一个错误:
select count(*)
from
(select zip from A
minus
select zip from B)
错误:
选择
附近的语法不正确
这是什么问题?我也试过别名子查询但发生了同样的错误。
答案 0 :(得分:1)
SQL Server中没有任何名为minus
的内容,您需要使用except
。
注意,SQL Server中的except
等同于Oracle的minus
以下查询将有效。
select count(*) ct
from
(
select zip from A
except
select zip from B
)t
您的代码的另一个问题是您需要为正在创建的内部表提供别名。