Created
February 6, 2012 21:15
-
-
Save mgreenly/1754934 to your computer and use it in GitHub Desktop.
sql with constant values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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