Click here to Skip to main content
15,886,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is My table(Fee) Containing some Rows
Id	Installment_No	Amount_Paid
1000	1	         6000
1000  	2	         6000
1001	1	         12000
1002	1	         6000
1003	1	         6000
1004	1	         6000
1005	1	         6000
1005	2	         6000
1006	1	         12000


I just need a Query to get the Below output.

Output		
Id	Installment_No	Amount_Paid
1002	1	        6000
1003	1	        6000
1004	1	        6000



Id "1000" had paid 12000 Rupees in Two Installments(So i don't want this)

and

Id "1001" had Paid 12000 Rupees in one Installment Only(this one also i don't need)

and

Id "1002" had Paid only 6000 rupees in 1st Installment need to pay remaining 6000 Rupees(I want this type Details)


I tried it but i couldn't get the Output.

Please tell me the Solution......
Posted
Updated 6-Aug-13 2:37am
v2
Comments
Richard MacCutchan 6-Aug-13 8:38am    
Maybe if you show what you have tried, and explain what is not working, then people will try to help you.
Venkat Kumar chigulla 6-Aug-13 8:43am    
I tried this Query



select Admission_ID from Tution_Fee where Branch_Code='ap' and Amount_Paid!='12000' and Installment_No!=2 and Admission_ID in (

select Admission_ID from Admissions where Branch_Code='ap' and Batch_ID='1556')


I got the Records who paid 12000.
Example: 1000 id will come in the output( He paid 12000)
Karwa_Vivek 6-Aug-13 8:59am    
According to your Question you want the Records ,who have not paid there total Installments yet and who have to pay the Remaining Installments ,Right ??

You can try like below.... It will help you...

SQL
SELECT * FROM FEE WHERE ID IN (SELECT id
  FROM FEE
WHERE amt=6000 
GROUP BY id
HAVING COUNT(id) = 1)


Fiddle Example : http://www.sqlfiddle.com/#!3/87471/2
 
Share this answer
 
Comments
Venkat Kumar chigulla 7-Aug-13 2:45am    
Thank you so Much. It's working and thanks a lot
looks like you are just looking for where the amount paid is less than 12000.

SQL
SELECT Id, Installment_No, Amount_Paid
FROM Fee
Where (AmountPaid < 12000);
 
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