1、
Select name,sum(case when Type_nm='交易金额' then day_val end)/ sum(case when Type_nm='交易笔数' then day_val end) avg_val from t_type_day group by NAME
2、
Select name from(
Select name,sum(val) val from(
Select name,`mon_val(当月累计值)` val from t_type_mon where Type_nm='交易金额'
Union all
Select name,day_val val from t_type_day where Type_nm='交易金额')A group by name)A1
Order by val desc limit 1
3、
Select name,val1 from(
Select name, sum(case when Type_nm='交易金额' then day_val end) val1,
sum(case when Type_nm='交易笔数' then day_val end) val2 from t_type_day group by name)A
Where val2>100 order by val1 desc