Using an Alias column in the where clause in Postgresql

后端 未结 6 1165
轮回少年
轮回少年 2020-11-22 11:04

I have a query like this:

SELECT
    jobs.*, 
    (
        CASE
            WHEN lead_informations.state IS NOT NULL THEN lead_informations.state
                   


        
6条回答
  •  旧时难觅i
    2020-11-22 11:18

    I believe the common solution is to use an inner SELECT for the calculation (or CASE statement in this case) so that the result of the inner SELECT is available to the entire outer query by the time the execution gets to that query. Otherwise, the WHERE clause is evaluated first and knows nothing about the SELECT clause.

提交回复
热议问题