Maneesh A N

Maneesh A N

  • NA
  • 179
  • 108.2k

sql 2000 with Having clause

Apr 29 2014 4:30 AM
SELECT a.rdMasterId,A.RDNO,F_Name,Isnull(OP.OPENING,0)as opening,

Isnull(Sum(case when Action IN ('O','I') and entryDate Between '01/Apr/2014' and '31/MAr/2015' then td.Amount Else 0 End),0) as Rcpt ,
Isnull(Sum(case when Action IN ('C') and entryDate Between '01/Apr/2014' and '31/MAr/2015' then td.Amount Else 0 End),0) as Pymt

FROM RDMASTER A inner Join Customers c
ON a.Customerid=c.Cust_No
LEFT JOIN RDOPENINGBALANCE OP ON OP.RDMasterId=A.RDMasterId AND FYEARID=18
Left Join rdTransactionMaster tm on tm.rdMasterId=a.rdMasterId and tm.CancelFlag='N'
and entryDate Between '01/Apr/2014' And '31/MAr/2015'
Left Join rdTRansactionDetails td on td.rdTransactionid=tm.rdTransactionid
Where A.groupid=3 GROUP BY a.rdMasterId,a.startdate,A.RDNO,OP.OPENING,F_Name
Having Isnull(Sum(case when Action IN ('C') then td.Amount+Interest Else 0 End),0) = 0
ORDER BY a.startdate,a.rdMasterId
 
 
AS PER ABOVE  MENTIONED QUERY,SHOWING "INTEREST PAYABLE" EVEN ALREADY CLOSED THE TRANSACTION ...GIVE ME ANSWER

Answers (2)