s******d 发帖数: 901 | 1 谢谢了。
select available.company_id, available.currency, available.sum, pending_paid
.sum
from (
(select company_id, currency, sum(value) as sum from
member_transactions where status ='A'
group by currency, company_id) as available
inner join
(select company_id, currency, sum(value) as sum from
member_transactions where status ='P'
group by currency, company_id) as pending_paid
on available.company_id=pending_paid.company_id
and available | s******d 发帖数: 901 | | B*****g 发帖数: 34098 | 3 select company_id, currency, sum(DECODE(status, 'A', value, 0)) as A_sum , s
um(DECODE(status, 'P', value, 0)) as p_sum
from member_transactions
where status ='A' OR status ='P'
group by currency, company_id
paid
【在 s******d 的大作中提到】 : 谢谢了。 : select available.company_id, available.currency, available.sum, pending_paid : .sum : from ( : (select company_id, currency, sum(value) as sum from : member_transactions where status ='A' : group by currency, company_id) as available : inner join : (select company_id, currency, sum(value) as sum from : member_transactions where status ='P'
|
|