Click here to Skip to main content
12,449,717 members (66,077 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: SQL
i have 12 record. i want to show Amount,date and installment no 12 times in a sequence but loan id only one time in a row. help me with this.

thanX in advance

Select c.Loan_id,i.Installment_no,i.Date,i.Amount from Customer c,Installments i,Loan l where l.Loan_id=c.Loan_id and c.Loan_id=i.Loan_id;
Posted 27-Dec-12 5:40am
Updated 27-Dec-12 5:45am
v2
Comments
zeshanazam 27-Dec-12 12:24pm
   
here is data



Installment_no Loan_id Date Amount
1 1234-55 2013-01-13 86688
2 1234-55 2013-02-13 86688
3 1234-55 2013-03-13 86688
4 1234-55 2013-04-13 86688
5 1234-55 2013-05-13 86688
6 1234-55 2013-06-13 86688
7 1234-55 2013-07-13 86688
8 1234-55 2013-08-13 86688
9 1234-55 2013-09-13 86688
10 1234-55 2013-10-13 86688
11 1234-55 2013-11-13 86688
12 1234-55 2013-12-13 86688
Bassofa 27-Dec-12 12:30pm
   
Can you please clarify your question?
zeshanazam 27-Dec-12 12:35pm
   
Value of Loan_id should appear only one time.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

zeshanazam,

Ideally, you would just limit the output in the code. But if you have to only have it output on one row, try the following. I'm assuming you're using SQL Server. Different database may change the syntax.

Select 	CASE i.Installment_no
	  WHEN 1 THEN c.Loan_id
	  ELSE null
	END AS Loan_ID
	,i.Installment_no
	,i.Date
	,i.Amount 
from Customer c
	,Installments i
	,Loan l 
where l.Loan_id = c.Loan_id 
and c.Loan_id = i.Loan_id;

Hogan
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100