Reference alias in WHERE clause

后端 未结 2 1609
一向
一向 2020-11-30 15:41

In psql, trying to reference alias in WHERE clause:

SELECT
    SUBSTRING(pk, 6, 2)::INT AS _year
FROM
    listing
WHERE
    _year > 90
         


        
2条回答
  •  萌比男神i
    2020-11-30 16:12

    Try this way

    select * from (SELECT
        SUBSTRING(pk, 6, 2)::INT AS _year
    FROM
        listing) a where _year>90
    

提交回复
热议问题