Comment by kbelder
4 years ago
This is what I'm most interested in. This is where SQL becomes very awkward and repetitive.
select
customer,
( select sum(revenue) from orders where customer=accounts.customer) as revenue,
( select count(transactionid) from orders where customer=accounts.customer) as orders
from
accounts;
That's a very simple example, but it can get VERY wordy and complex, and in my dreams I'd be able to write something like:
getrevenue(cust) is select sum(revenue) from orders where customer=cust
getorders(cust) is select count(transactionid) from orders where customer=cust
select
customer,
getrevenue(customer),
getorders(customer)
from
accounts;
In a way, it's just dynamic sql without hacking strings together in unmaintainable ways.
No comments yet
Contribute on Hacker News ↗