Click here to Skip to main content
15,914,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my table has following
SQL
sno      date           desc            amt     creit    debit  total 
2	08/02/2012	PURCHASE A/C	23	34500.00	0.00		
2	08/02/2012	SOMU	23	0.00	34500.00	NULL	
3	08/02/2012	SALES A/C	24	0.00	6000.00	NULL	
3	08/02/2012	DEVA	24	6000.00	0.00	NULL	NULL
4	08/03/2012	SBI	14	0.00	1000.00	NULL	NULL
4	08/03/2012	Cash A/c	14	1000.00	0.00	NULL	
4	08/03/2012	Cash A/c	14	1000.00	0.00	NULL	
4	08/03/2012	Cash A/c	14	1000.00	0.00	NULL	

I want to get the records group by date and it displays only one time as date like as following
SQL
sno      date           desc            amt     creit    debit  total 
2	08/02/2012	PURCHASE A/C	23	34500.00	0.00		
2	NULL    	SOMU	23	0.00	34500.00	NULL	
3	NULL       	SALES A/C	24	0.00	6000.00	NULL	
3	NULL    	DEVA	24	6000.00	0.00	NULL	NULL
4	08/03/2012	SBI	14	0.00	1000.00	NULL	NULL
4	NULL	       Cash A/c	14	1000.00	0.00	NULL	
4	NULL     	Cash A/c	14	1000.00	0.00	NULL	
4	NULL     	Cash A/c	14	1000.00	0.00	NULL	


Thank you
Posted

1 solution

SQL
With CTE_Test
as
(select sno,[date],[desc],amt,creit,debit,Total,Row_number() over (PARTITION By date order by sno) as rowno
from tbl_temp)
Select Sno,
Case when rowno=1 then [date] else Null END,
[desc],amt,creit,debit,Total from cte_test
 
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