我只需要在支付日期相同的情況下對列的數據進行求和。總計一個特定的列
這是返回的數據:
judgment PaymentDate interestrate current1 paymentamount principalamount
2/1/2008 7/31/2010 9.00 5781.04 -315.07 -270.07
2/1/2008 7/31/2010 9.00 5781.04 272.59 227.59
下面是該查詢:
select tb1.judgment, fulldate as PaymentDate, m.interestrate, m.current1, paymentamount, principalamount from master m
inner join AARS_JudgmentsWithPA tb1 on tb1.jmacct = m.number
inner join courtcases cc on cc.accountid = m.number
where m.lastinterest != '2099-01-01 00:00:00.000'
and tb1.fulldate > tb1.judgment
and cast(tb1.PrincipalAmount as money) != 0
and tb1.judgment != ''
and m.number = 568463
對於提供我需要的那些行合併,因爲付款日期是相同的示例數據。所以支付金額應該被壓縮爲(-270.07 + 227.59),即-42.48。
我試圖按照fulldate和付款總額進行分組,但它要求我將每個列分組,然後再返回兩行。
我錯過了什麼?
您正在使用哪個數據庫管理系統? Postgres的?甲骨文? –
SSMS。我認爲這就是你要找的。 –
我從來沒有聽說過一個名爲* SSMS *的DBMS--那是什麼? –