zlacker

[return to "Google's new pipe syntax in SQL"]
1. samwil+XP9[view] [source] 2024-08-28 22:13:13
>>heyden+(OP)
Richard Hipp, creator of SQLite, has implemented this in an experimental branch: https://sqlite.org/forum/forumpost/5f218012b6e1a9db

Worth reading the thread, there are some good insights. It looks like he will be waiting on Postgres to take the initiative on implementing this before it makes it into a release.

◧◩
2. Blackt+FS9[view] [source] 2024-08-28 22:33:12
>>samwil+XP9
FROM first would be nothing short of incredible. I can only hope that Postgres and others can find it within themselves to get together and standardize on such an extension!
◧◩◪
3. willva+Pwa[view] [source] 2024-08-29 05:31:11
>>Blackt+FS9
Yeap I didn't know DuckDB supported it already!

Being able to do SELECT FROM WHERE in any order and allowing multiple WHEREs and AGGREGATE etc, combined with supporting trailing commas, makes copy pasting templating and reusing and code-generating SQL so much easier.

  FROM table  <-- at this point there is an implicit SELECT *
  SELECT whatever
  WHERE some_filter
  WHERE another_filter <-- this is like AND
  AGGREGATE something
  WHERE a_filter_that_is_after_grouping <-- is like HAVING
  ORDER BY ALL <-- group-by-all is great in engines that support it; want it for ordering too
...
◧◩◪◨
4. aidos+aAa[view] [source] 2024-08-29 06:14:45
>>willva+Pwa
What’s group-by-all? Sounds like distinct?
◧◩◪◨⬒
5. geneze+GDa[view] [source] 2024-08-29 06:57:54
>>aidos+aAa
It's different from distinct. Distinct just eliminates duplicates but does not group entries.

Suppose...

  SELECT brand, model, revision, SUM(quantity)
   FROM stock
   GROUP BY brand, model, revision
This is not solved by using distinct as you would not get the correct count.

Group By All allows you to write it a bit more compact...

  SELECT brand, model, revision, SUM(quantity)
   FROM stock
   GROUP BY ALL
[go to top]