Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can anyone help me for find out maximum date and itz paid amount ...where cid is user define......

SQL
SELECT CID, Ddate, AmountDeposit FROM Deposit
WHERE Ddate IN (SELECT MAX(Ddate) FROM Deposit) AND CID IN (SELECT CID FROM Deposit WHERE CID = 'C000000000097')


CID Ddate AmountDeposit
C000000000097 2013-06-12 70000
............. .......... ........
............ .......... .........


I WANT TO OUTPUT maximum dated and itz amount LIKE BELOW:

CID Ddate AmountDeposit
C000000000097 2013-06-12 70000
Posted

Try this...
SQL
SELECT CID, Ddate, Sum(AmountDeposit)
FROM Deposit
WHERE 
Ddate =(SELECT MAX(Ddate) FROM Deposit) 
AND CID = 'C000000000097'
Group by
CID, Ddate

Happy Coding!
:)
 
Share this answer
 
Comments
sammsul 13-Jun-13 4:53am    
thanks for feedback but itz not correct way what i want....i just solve the problem and sln in below................

SELECT PRT.CID, PRC1.AmountDeposit, PRC1.Ddate FROM Deposit PRT LEFT OUTER JOIN Deposit PRC1 ON PRC1.CID = PRT.CID LEFT OUTER JOIN Deposit PRC2 ON PRC2.CID = PRC1.CID AND PRC2.Ddate > PRC1.Ddate WHERE PRC2.CID ='C0000000000300'
SQL
i just solve the problem and sln in below................

SELECT PRT.CID, PRC1.AmountDeposit, PRC1.Ddate FROM Deposit  PRT LEFT OUTER JOIN Deposit PRC1 ON PRC1.CID = PRT.CID LEFT OUTER JOIN Deposit PRC2 ON PRC2.CID = PRC1.CID AND PRC2.Ddate  > PRC1.Ddate WHERE PRC2.CID ='C0000000000300'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900