好的,我有一个如下所示的表:
ID AMOUNT PAID
1 50.00 Y
2 100.00 N
3 200.00 Y
我想看到类似的东西:
Total Due Paid
350.00 1 2
所以我的 SQL 看起来像(在我的脑海中......它不是那样工作的,这就是我在这里的原因)
select sum(amount)
,count(paid where paid='y') as due
,count(paid where paid='n') as paid
from sometable where something=somethingelse