I am trying to find a way to combine rows in a table based on the longest row in any of the rows based on row row
Example
CREATE TABLE test1
(akey int not null ,
text1 varchar(50) NULL,
text2 varchar(50) NULL,
text3 varchar(50) NULL )
INSERT INTO test1 VALUES ( 1,'Winchester Road','crawley',NULL)
INSERT INTO test1 VALUES ( 1,'Winchester Rd','crawley','P21869')
INSERT INTO test1 VALUES ( 1,'Winchester Road','crawley estate','P21869')
INSERT INTO test1 VALUES ( 1,'Winchester Rd','crawley','P21869A')
INSERT INTO test1 VALUES ( 2,'','birmingham','P53342B')
INSERT INTO test1 VALUES ( 2,'Smith Close','birmingham North East','P53342')
INSERT INTO test1 VALUES ( 2,'Smith Cl.',NULL,'P53342B')
INSERT INTO test1 VALUES ( 2,'Smith Close','birmingham North','P53342')
with these lines, I would look for the result:
1 Winchester Road, crawley estate, P21869A
2 Smith Close, birmingham North East, P53342B
EDIT : the above results should be in a table, not just a comma separated by a comma
as you can see as a result, the output should be a long text column in the "akey" field.
I am trying to find a solution that does not include many subqueries in each column, the actual table has 32 columns and more than 13 million rows.
the reason I'm doing this is to create a cleaned table that has the best results in each column for only one identifier per row
, , , , !
.