Hacker News new | ask | show | jobs
by SoftTalker 16 days ago
Current structure makes sense to me.

  SELECT .... what do I want
  FROM .... where is it 
  WHERE .... what filters do I want to apply
  GROUP BY .... how do I want it aggregated
Maybe it's just that I'm so used to it. I could see FROM being first, that would actually make a little more sense to me.
2 comments

A pretty common request is to lift the FROM up before the select, like the below. I'm pretty fine with status quo since my mind is usually "hmm what do I need to get" first, then I figure out how to get it, but some engines (duckdb, I think?) support both so everyone gets their cake.

What people often want: <where to get data from> <what I want from it> <how it's filtered> <how it's grouped> <how it's filtered post group>

Also helps with autocomplete, which is why LINQ starts with `from`
Linq took that from Hibernate in believe. But in general, I'd say almost all ORM and SQL-gen libraries have FROM first, because it's clearer for programmers.
Hibernate puts SELECT last if requesting only specific properties?

LINQ:

  var query = 
    from e in entities
    where e.property1 == value
    select e.property2;
> I could see FROM being first, that would actually make a little more sense to me.

Personally, I disagree. In English, an imperative statement like "move that chair from the dining room to the living room" is generally verb-first (with respect to location, anyway). SQL's flow has always made perfect sense to me.