我试图在加入3个表后计算不同客户的数量。这是下面的查询。
我收到错误"mismatched input 'd' expecting ) near ')' in from source"
select count(distinct(a.customer))
from (
(select *
from tab1
where tab in (1)) c
join (
(select *
from tab1
where tab in (2)) a
join
(select *
from tab1
where tab in (3)) b
on a.customer = b.customer) d
on c.customer = d.customer)
答案 0 :(得分:0)
您的查询中有额外的括号,这会产生误导。改为下面
select count(distinct a.customer)
from (
select *
from tab1
where tab in (1)) c
join (
select *
from tab1
where tab in (2)) a on a.customer = c.customer
join
(select *
from tab1
where tab in (3)) b on c.customer = b.customer;