我有这个查询,但它不能正常工作
select t.ACCOUNT_ID
from
(select
a.ACCOUNT_ID, count(a.ACCOUNT_ID)
from
EMPLOYER a, EMPLOYER b
where
a.main_id = b.main_id
group by
a.MAIN_ID, a.account_id
having
count(a.account_id) > 1) t
我正在尝试查找重复项,并希望从中获取唯一的ACCOUNT_ID 子查询
答案 0 :(得分:1)
select t.ACCOUNT_ID from (select
a.ACCOUNT_ID,count(a.ACCOUNT_ID) as cnt
from EMPLOYER a,EMPLOYER b
where a.main_id = b.main_id
group by a.MAIN_ID,a.account_id
having count( a.account_id) > 1)t
如果要从子查询中进行选择,则应至少为每列的第一个实例命名。
在as cnt
COUNT(a.account_id)