我有一个查询如下
select t.col1,
t.col2,
(select count(col1)
from tab
where col1 = t.col1
and col2 = t.col2
) as col3
from tab t
where col3 > 1
该查询给出了“col3无效标识符”错误.
我尝试了不同的变体来定义我在下面给出的别名以及我在使用它时得到的错误
>
select t.col1,
t.col2,
(select count(col1)
from tab
where col1 = t.col1
and col2 = t.col2
) as "col3"
from tab t
where col3 > 1
错误:col3无效标识符
>
select t.col1,
t.col2,
(select count(col1)
from tab
where col1 = t.col1
and col2 = t.col2
) as 'col3'
from tab t
where [col3] > 1
错误:在哪里丢失表达式
>
select t.col1,
t.col2,
(select count(col1)
from tab
where col1 = t.col1
and col2 = t.col2
) "col3"
from tab t
where [col3] > 1
错误:在哪里丢失表达式
请解释我的错误是什么
附:我不知道为什么我无法在此处将查询示例标记为代码.我为这些查询的可读性差而道歉