Click here to Skip to main content
15,895,792 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
SQL
CREATE TABLE BankStatment(
ID int, DDate Date , Desc1 varchar(30),  Desc2 varchar(30) ,Debit int ,Credit int,Bal_Calc decimal
)

INSERT INTO BankStatment(ID,
DDate , Desc1 ,  Desc2 , Debit , Credit , Bal_Calc)
VALUES (1,'01/05/21','XYZ','123','250',NULL,'1000'),
(2,'01/05/21','ABC','100','400',NULL,'1000'),
(3,NULL,'OWE','987',NULL,NULL,NULL),
(4,'01/10/21',' XYZ ',' 777 ',' 250 ', NULL ,'1000'),
(5,NULL, 'BBB' ,'102' ,'293', NULL , NULL ),
(6,'02/10/21 ',' BOW ' , '888','100' , NULL ,'900');


What I have tried:

/*2-Rule Merge description rows downwards vertically. New merge starts whenever date column has a value. 
Merge if only description columns have values, 
if more columns have values then do not merge, delete row instead.*/

/*3-Rule Merge description rows upwards vertically. New merge starts whenever date column has a value. 
Merge if only description columns have values, 
if more columns have values then do not merge, delete row instead.*/
Posted
Updated 21-Apr-22 5:57am
Comments
Maciej Los 21-Apr-22 11:54am    
Sounds like homework...

1 solution

 
Share this answer
 
Comments
Member 15609077 24-Apr-22 5:07am    
Thanks, but i want way to merge rows from same table not merge between two tables
and how i merge upwards vertically and downwards vertically ?

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