zlacker

[return to "Pipe Syntax in SQL"]
1. Cianti+06[view] [source] 2024-08-24 16:16:12
>>legran+(OP)
Here is one example from the PDF:

    FROM r JOIN s USING (id)
    |> WHERE r.c < 15
    |> AGGREGATE sum(r.e) AS s GROUP BY r.d
    |> WHERE s > 3
    |> ORDER BY d
    |> SELECT d, s, rank() OVER (order by d)
Can we call this SQL anymore after this? This re-ordering of things has been done by others too, like PRQL, but they didn't call it SQL. I do think it makes things more readable.
◧◩
2. thiht+do[view] [source] 2024-08-24 18:38:50
>>Cianti+06
Honestly SQL screwed things up from the very beginning. "SELECT FROM" makes no sense at all. The projection being before the selection is dumb as hell. This is why we can’t get proper tooling for writing SQL, even autocompletion can’t work sanely. You write "SELECT", what’s it gonna autocomplete?

PRQL gives me hope that we might finally get something nice some day

◧◩◪
3. scrlk+DA[view] [source] 2024-08-24 20:14:08
>>thiht+do
The initial version of SQL was called "Structured English Query Language".

If the designers intended to create a query language that resembled an English sentence, it makes sense why they chose "SELECT FROM".

"Select the jar from the shelf" vs. "From the shelf, select the jar".

◧◩◪◨
4. xigoi+SO1[view] [source] 2024-08-25 09:29:12
>>scrlk+DA
“Go to the shelf and select the jar”. You’re describing a process, so it’s natural to formulate it in chronological order.
◧◩◪◨⬒
5. mr_toa+eCc[view] [source] 2024-08-29 04:40:34
>>xigoi+SO1
SQL is a declarative language not a procedural one. You tell the query planner what you want, not how to do it.
[go to top]