select ...... where 表1.3_id in (select id from 表4 where name ="输入的值")

解决方案 »

  1.   

    select 
        b.name name2,
        c.name name3, 
        sum(a.count) countA 
    from 
        table1 a,
        table2 b,
        table3 c,
        table4 d
    where
            a.1_id=b.1_id 
        and a.2_id=c.2_id 
        and a,3_id=d.3_id 
        and d.name='你的name的值'
    group by 
        b.name,
        c.name
      

  2.   

    select b.name ,
           c.name,
           sum(a.count) over(partition by b.name,c.name)  from table1 a,
           table2 b,
           table3 c,
           table4 d where a.1_id=b.1_id 
       and a.2_id=c.2_id 
       and a,3_id=d.3_id 
       and d.name='你的name的值'