3 ms·
If you really want to master non-trivial SQL learn to think about filtering, joining, and combining data via set theory. Once you can logically break down the s
by sehrope 13y ago
If you really want to master non-trivial SQL learn to think about filtering, joining, and combining data via set theory. Once you can logically break down the set you're trying to get to the rest then just becomes learning/looking-up syntax.
The other big piece of advice is the tried and true incremental approach. The more complicated something is, the more likely I am to use the SQL client the way one uses a REPL and incrementally write the query:
1. Write basic SELECT
2. Add another clause (WHERE filter, GROUP BY, etc...)
3. Execute (syntax/sanity test)
4. Finish or Goto step 2
Just like everything else in programming it's amazing how much simpler things are when you just piece them together one step at a time.
[1]: https://en.wikipedia.org/wiki/Set_theory https://en.wikipedia.org/wiki/Set_theory
[2]: http://seanmehan.globat.com/blog/2011/12/20/set-theory-and-sql-concepts/ http://seanmehan.globat.com/blog/2011/12/20/set-theory-and-s...
- tom_b 13y agoI believe it's somewhat impossible to overestimate how REPL-like data munging with SQL actually is. Particularly as the complexity of your data exploration increases. Celko calls this "thinking in sets."