Using an Alias column in the where clause in Postgresql

后端 未结 6 1112
轮回少年
轮回少年 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条回答
  •  心在旅途
    2020-11-22 11:24

    I used alias in where like this. (INNER Query).

    Select "Vendors"."VendorId", "Vendors"."Name","Result"."Total" 
    From (Select "Trans"."VendorId", ("Trans"."A"+"Trans"."B"+"Trans"."C")    AS "Total"
            FROM "Trans"
        WHERE "Trans"."Year"=2014                                                
        ) As "Result"
    JOIN "Vendors" ON "Result"."VendorId"="Vendors"."VendorId" 
    WHERE "Vendors"."Class"='I' AND "Result"."Total" > 200
    

提交回复
热议问题