← Back to context

Comment by magicalhippo

4 years ago

> With a CTE

The DB we use supports those, I just learned about them too late so keep forgetting they exist :(

> It would really help in SQL if you could refer to column aliases so you don't have to repeat the expression.

The DB we use supports that, so in your CTE you could write

   AND   gross_cost > 0

We do that all the time, which will be a pain now that we're migrating to a different DB server which doesn't.