News for hackers. Stuff that matters.
Re:Show HN: Select Star SQL, an interactive SQL book by wvenable on Monday September 03, 2018 @10:06PM (#17906117)
I teach SQL to financial people and, for the most part, it isn't too bad. When I get to joins, I teach a subset of SQL where all joins are done through INNER JOIN / LEFT JOIN syntax and that helps a lot. Joins are the part that everyone has trouble with.
Re:Show HN: Select Star SQL, an interactive SQL book by setr on Monday September 03, 2018 @10:56PM (#17906278)
Tbh I usually see teachers worried about joins but its the group by/having clauses that I always watched people struggle with (at least, writing it).

Ofc that might just be the emphasis on joins makes group by the next lowest hanging fruit

Re:Show HN: Select Star SQL, an interactive SQL book by ranit on Tuesday September 04, 2018 @12:23AM (#17906627)
What do your abbreviations mean?
Re:Show HN: Select Star SQL, an interactive SQL book by grzm on Tuesday September 04, 2018 @12:25AM (#17906636)
tbh = to be honest, ofc = of course

Urban Dictionary (https://www.urbandictionary.com) or even just typing something like "what does tbh mean?" into your preferred search engine will often help you find likely interpretations of unknown abbreviations, in my experience.

Re:Show HN: Select Star SQL, an interactive SQL book by justinator on Tuesday September 04, 2018 @01:01AM (#17906763)
> or even just typing something like "what does tbh mean?" into your preferred search engine will often help you find likely interpretations

I mean, that's what they did.

Re:Show HN: Select Star SQL, an interactive SQL book by asavinov on Tuesday September 04, 2018 @03:15AM (#17907183)
> Joins are the part that everyone has trouble with.

There is significant problem-solution mismatch in joins and some other SQL constructs which are therefore semantically quite controversial in many use cases:

https://github.com/asavinov/bistro#why-column-orientation

Re:Show HN: Select Star SQL, an interactive SQL book by HeavyStorm on Tuesday September 04, 2018 @10:50AM (#17909422)
The syntax isn't the problem though. Join relational operation is though on itself.
Re:Show HN: Select Star SQL, an interactive SQL book by Exuma on Tuesday September 04, 2018 @01:23AM (#17906825)
Can you explain when to really use a lateral join?
Re:Show HN: Select Star SQL, an interactive SQL book by garyclarke27 on Tuesday September 04, 2018 @03:25AM (#17907227)
In Postgresql, Lateral Joins enable function chaining for set returning functions. ie you can feed the results of earlier srf function to the arguments of following function. This gets around one of Postgresql most glaring omissions - table valued parameters. Is incredibly useful once you get used to them.
Re:Show HN: Select Star SQL, an interactive SQL book by andreareina on Tuesday September 04, 2018 @10:22AM (#17909224)
I might be misunderstanding your point, but Postgresql functions can take (and return) tables:

    CREATE FUNCTION fullname(person) RETURNS TEXT AS $$
    SELECT $1.firstname || ' ' || $1.lastname
    $$ LANGUAGE SQL
Could you go into a more detail wrt using lateral joins with set returning functions? I'm used to using them as a way to "extend" the row with later terms depending on prior terms as you say, but I'm not comprehending the srf case so well (or tbh the results that pop up when I search for "posrgresql set returning function").
Re:Show HN: Select Star SQL, an interactive SQL book by netcraft on Tuesday September 04, 2018 @09:23AM (#17908831)
In my experience it’s relatively rare that you need them. I think of them as the for-each of joins. It evaluates row by row, not a single time. Another analogy would be a correlated subquery.