Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Code as follows;
SQL
SELECT CASE WHEN RowNo =1 THEN CONVERT(VARCHAR(10), sno) ELSE '' END AS Sno, CASE WHEN RowNo =1 THEN CONVERT(VARCHAR(10), stud_id) ELSE '' END AS Stu_id,
       CASE WHEN RowNo =1 THEN [stud_name] ELSE '' END AS [Stud_name],[Rcptno] as Rcpt_no, [Rcptdt] as Rcpt_dt, [RcptAmt] as Rcpt_amt, [Chqtype] as P_type, [chqnum] as Number,CASE WHEN RowNo =2 THEN CONVERT(VARCHAR(10), pendamt) ELSE '' END AS Pend_amt
FROM (
    SELECT *, ROW_NUMBER() OVER(PARTITION BY sno ORDER BY sno) AS RowNo
    FROM #TempTable   
) AS T


Output as follows;
11  58166   BHARAT 1565	21 Apr 2012  10000.00  DEMAND DRAFT    067935              	
	           1566	21 Apr 2012  49000.00  DEMAND DRAFT    067936              	0.00
                   1970	26 Jun 2012  49000.00  DEMAND DRAFT    900671              	
	           1971	26 Jun 2012  21000.0   DEMAND DRAFT    900672              	
	           2088	23 Jul 2012  30000.00  DEMAND DRAFT    902109          
    	
12 58050   KORLA   1512	13 Apr 2012  10000.00			
	           1775	18 Jun 2012  49000.00	 0.00		                                                         
	           1983	28 Jun 2012  100000.00	

From the above output i want the output as follows;
11  58166   BHARAT 1565	21 Apr 2012  10000.00  DEMAND DRAFT    067935              	
	           1566	21 Apr 2012  49000.00  DEMAND DRAFT    067936              	
                   1970	26 Jun 2012  49000.00  DEMAND DRAFT    900671              	
	           1971	26 Jun 2012  21000.0   DEMAND DRAFT    900672              	
	           2088	23 Jul 2012  30000.00  DEMAND DRAFT    902109           0.00   
    	
12 58050   KORLA   1512	13 Apr 2012  10000.00			
	           1775	18 Jun 2012  49000.00	 	                                                         
	           1983	28 Jun 2012  100000.00	                   0.00	


From my above code what changes i made to get the pending amt is to be displayed in the last row for every record.

how can i do?

Please help me


Regards,
Rao.
Posted
Updated 25-Apr-13 1:12am
v2
Comments
Karthik Harve 25-Apr-13 7:13am    
[Edit] pre tags added for code block.
[no name] 25-Apr-13 7:27am    
You would think after almost 2 years here and 400+ questions, you would at least figure out how to use the "improve question" function instead of reposting the same question over and over.

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