column aliases in postges for calculated values

Posted by dubreakkk on Stack Overflow See other posts from Stack Overflow or by dubreakkk
Published on 2010-05-20T00:50:10Z Indexed on 2010/05/20 1:00 UTC
Read the original article Hit count: 282

Filed under:
|
|
|

I tried to uses aliases in postgres for this query, but postgres stops and complains that ERROR: column "subtotal" does not exist

SELECT SUM(price) AS subtotal, 
       subtotal * 3.0 AS fees,
       (subtotal + fees) AS total
  FROM cart

You cannot use aliases as part of your next column?

© Stack Overflow or respective owner

Related posts about sql

Related posts about postgresql