Let me give you an example.
select vendor, model, avg(price) as price from allCars group by vendor, model;
So far, this is simple and clear. Now let's imagine someone has a requirement to calculate this for different set of cars:
select vendor, model, avg(price) as price from allCars where vendor = 'BMW' group by vendor, model;
or
select vendor, model, avg(price) as price from allCars where year > 1990 group by vendor, model;
This approach only works if I'm always selecting from the same table - allCars, and I know all the condition in advance. To reuse the actual code which calculates the average prices (select ... group by) I'd need something like this:
select vendor, model, avg(price) as price from $cars -- $cars is a variable with at least three attributes (vendor, model, price) group by vendor, model;
This way I could write my own relational operator which calculates avg prices of cars per vendor and a model no matter where the cars are coming from.
Does anyone else have the same problem as me or am I just not smart enough to figure out how to do it in SQL?