October 22, 2024
Chicago 12, Melborne City, USA
SQL

Matching for 2 columns but matching all alternatives recuringly in SQL


My data look like this
|Col_X Col_Y|
|:—-:|
|a b|
|b c|
|c d|
|d e|
|f g|
|t y|
|y r|
|q w|
|n m|
|m k|
|m z|

My final goal cluster table should be exactly like this:
|Cluster|
|:—-:|
|abcde|
|fg|
|nmkz|
|qw|
|tyr|

My pseudo data

select 'a' as x, 'b' as y union all
select 'b' as x, 'c' as y union all
select 'c' as x, 'd' as y union all
select 'd' as x, 'e' as y union all
select 'f' as x, 'g' as y union all
select 't' as x, 'y' as y union all
select 'y' as x, 'r' as y union all
select 'q' as x, 'w' as y union all
select 'n' as x, 'm' as y union all
select 'm' as x, 'k' as y union all
select 'm' as x, 'z' as y 



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video