我有两个已成功进行内部联接的查询
select t1.countResult, t2.sumResult from (
    select 
        count(column) as countResult
    from tableA join tableB 
    on tableA.id = tableB.id
    group by name
)t1 inner join (    
    select 
        sum(column) as sumResult
    from tableA
    join tableB
    on tableA.id = tableB.id
    group by name
)t2 
on t1.name= t2.name
上面的查询将返回我的名称和相应的计数和总和。我需要在计数和总和之间进行比较。如果计数与总和不匹配,它将返回 0,否则返回 1。所以我的想法是实现另一个外层来包装它们并使用CASE WHEN. 但是,我没有应用外层来包裹它们?这是我尝试过的:
select * from(
    select t1.countResult, t2.sumResult from (
        select 
            count(column) as countResult
        from tableA join tableB 
        on tableA.id = tableB.id
        group by name
    )t1 inner join (    
        select 
        sum(column) as sumResult
        from tableA
        join tableB
        on tableA.id = tableB.id
        group by name
    )t2 
    on t1.name= t2.name
)