Skip to content

Instantly share code, notes, and snippets.

@Tux
Created December 14, 2024 23:18
Show Gist options
  • Select an option

  • Save Tux/f9a4555dea76f3ad3794a20ec013c0bd to your computer and use it in GitHub Desktop.

Select an option

Save Tux/f9a4555dea76f3ad3794a20ec013c0bd to your computer and use it in GitHub Desktop.
select f.foo, f.bar, b.beatle
from fumble f
left join brox b on b.x = f.x
and b.y = f.y
and b.z = f.z
and b.g = f.g
and b.h = f.h
and b.k = f.k
and b.j = f.j
order by foo, bar;
=>
with
fx as (
select x, y, z, g, h, k, l, foo, bar,
concat_ws (':', x, y, z, g, h, k, l) as kfx
from fumble
),
bx as (
select x, y, z, g, h, k, l, beatle,
concat_ws (':', x, y, z, g, h, k, l) as kbx
from brox
)
select foo, bar, beatle
from fx
left join bx on kbx = kfx
order by foo, bar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment