Sorry, to clarify, not everything is in all caps. I’ll append my prefered syntax below
<span style="color:#323232;">WITH foo AS (
</span><span style="color:#323232;"> SELECT id, baz.binid
</span><span style="color:#323232;"> FROM
</span><span style="color:#323232;"> bar
</span><span style="color:#323232;"> JOIN baz
</span><span style="color:#323232;"> ON bar.id = baz.barid
</span><span style="color:#323232;">)
</span><span style="color:#323232;">SELECT bin.name, bin.id AS binid
</span><span style="color:#323232;">FROM
</span><span style="color:#323232;"> foo
</span><span style="color:#323232;"> JOIN bin
</span><span style="color:#323232;"> foo.binid = bin.id
</span>
The above is some dirt simple SQL, when you get into report construction things get very complicated and it pays off to make sure the simple stuff is expressive.