Skip to content

Instantly share code, notes, and snippets.

@mgreenly
Created February 6, 2012 21:15
Show Gist options
  • Select an option

  • Save mgreenly/1754934 to your computer and use it in GitHub Desktop.

Select an option

Save mgreenly/1754934 to your computer and use it in GitHub Desktop.
sql with constant values
select
ta.*,
coalesce(tb.weight, 0) as weight
from
(values ('A1','B1', 3),
('A2','B2', 7) )
as ta(a_d,b_id,qty)
left join
(values ('B1',2) )
as tb(b_id, weight)
on ta.b_id = tb.b_id;
select
a.b_id as ab_id,
b.b_id as bb_id
from
(values ('A1', 'B1'),
('A2', 'B2'),
('A3', 'B3') )
as a(a_id,b_id)
full outer join
(values ('B2'),
('B3'),
('B4') )
as b(b_id)
using (b_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment