Comment

Comment by barrkel

There's no good reason for using two different keywords for filtering and it harms composability. But of course SQL isn't very composable anyhow.

Preferably, SQL would look more like:

  FROM Foo f
  WHERE f.value < 10
  JOIN Bar b on b.id = f.bar_id
  WHERE b.other_value > 20
  SELECT f.group, f.value
  GROUP BY f.group the_group AGGREGATING SUM(f.value) the_sum
  WHERE the_sum > 100
  ORDER BY the_group
And so on. FROM introduces a source of data which flows into the next line. SELECT does a projection, GROUP BY applies aggregation operators on groups and also does a projection. WHERE could be inserted pretty much anywhere.
parent barrkel 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton