It is not hard to learn - non programmers use it all the time.
Conceptually SQL is much more simple than programming, it basically reads like english:
SELECT customer, SUM(total)
FROM orders
GROUP BY customer
WHERE created BETWEEN '2018-01-01' AND '2018-12-31'`
ORDER BY SUM(total) DESC
Compare that to the programming necessary to implement the above:
totals = {}
for row in rows:
if row.created > '2018-12-31':
continue
if row.created < '2018-01-01':
continue
if row.customer not in customer_totals_2018:
totals[customer] = 0
totals[customer] = totals[customer] + row.total
def _sorter((customer, total)):
return -total
for customer, total in sorted(totals.items(), key=_sorter):
print(customer, total)
Not to mention the SQL version gets first hand knowledge on available indexes in order to speed up the query.
Now imagine adding an AVG(total) to both the SQL and programming version...
Conceptually SQL is much more simple than programming, it basically reads like english:
Compare that to the programming necessary to implement the above: Not to mention the SQL version gets first hand knowledge on available indexes in order to speed up the query.Now imagine adding an AVG(total) to both the SQL and programming version...