我想结合下面的值怎么办?????请

时间:2014-12-21 16:41:24

标签: mysql count

select p.prop_name,count(*) as populasi 
from  t_perusahaan t
left join t_mst_propinsi p 
 on t.per_prop=p.prop_id  group by t.per_prop
order by populasi desc limit 6

select p.prop_name,count(*) as monev
 from t_hasil_monitoring m left join t_perusahaan t
 on t.per_id=m.per_id 
left join t_mst_propinsi p 
 on t.per_prop=p.prop_id
where mon_tahun='2014'
group by t.per_prop 
order by monev desc limit 6

1 个答案:

答案 0 :(得分:0)

你尝试过工会吗?

   (select p.prop_name,count(*) as count_populasi_monev
    from  t_perusahaan t
    left join t_mst_propinsi p 
     on t.per_prop=p.prop_id  group by t.per_prop
    limit 6
    )

    union

    (
    select p.prop_name,count(*) as count_populasi_monev
     from t_hasil_monitoring m left join t_perusahaan t
     on t.per_id=m.per_id 
    left join t_mst_propinsi p 
     on t.per_prop=p.prop_id
    where mon_tahun='2014'
    group by t.per_prop 
    limit 6
    )