0

以下のクエリの助けを借りて、15行しかフェッチできませんでしたが、実際の行は16行で、1行はnullです

どうすればその行も取得できますか合計16行を取得する必要があります助けてください....

select p.partnerid,p.name,count(*) as accounts,sum(c.amount) as amount,sum(c.netamt) as netamt,
sum(c.netamt - c.amount) as interest,
sum(case when c.installment = 20 then c.amount else 0 end) as Twenty,
sum(case when c.installment = 10 then c.amount else 0 end) as Ten,
sum(case when c.installment = 5 then c.amount else 0 end) as Five,
sum(case when c.installment = 2 then c.amount else 0 end) as Two
from partnerinfo p left outer join customerinfo c on p.partnerid = c.partnerid
where c.startdate >= '2011-3-15' and c.startdate <= '2012-12-30' and p.manager=1 group by p.partnerid

2012-3-15 の空の行が表示されるように、日付を 2011-3-15 から変更しても。私は自分のレベルに最善を尽くしましたが、達成できませんでした。

私を助けてください.....

4

1 に答える 1

0

これを試して:

select p.partnerid,p.name,count(*) as accounts,sum(c.amount) as amount,sum(c.netamt) as netamt,
sum(c.netamt - c.amount) as interest,
sum(case when c.installment = 20 then c.amount else 0 end) as Twenty,
sum(case when c.installment = 10 then c.amount else 0 end) as Ten,
sum(case when c.installment = 5 then c.amount else 0 end) as Five,
sum(case when c.installment = 2 then c.amount else 0 end) as Two
from partnerinfo p left outer join customerinfo c on p.partnerid = c.partnerid
where (c.startdate is null OR (c.startdate >= '2011-3-15' and c.startdate <= '2012-12-30')) 
and (p.manager is null OR p.manager=1)
group by p.partnerid
于 2012-06-19T15:49:04.977 に答える