Select p.item_name,
sum(p.mc_gross Case when u.ag_code!=0),
Sum(p.mc_gross Case when u.ag_code=0)
From table1 as p,table2 as u
Where p.payment_status = 'success'
Group By p.item_name
This query have error
mcgross,ag_code,cdate,mdate,item_name is the column names in my table
My result want like this
item_name sum1 Sum2
Bronze 11.71 9.99
Silver 35.82 540.88
Enterprise 145.3 308.94
Silver 156.94 开发者_如何学Go1
Bronze 451.86 7.99
Gold 565.56 1019.74
Enterprise 671.17 608.88
Gold 71.23 38.99
Hard to say without more info but try chaning it to group by Item_name
.
精彩评论