How do I add a where statement at the end of query for a column that does not have a table to reference from?
0
votes
1
answer
70
views
select
CASE WHEN (to_char(((case when v.trip_order_start_date is null then case when v.manual_start_date is null then t.required_pickup_date else v.trip_order_start_date end else v.trip_order_start_date end + (interval '-1 hours' * ofc.offset)) at time zone 'utc' at time zone 'America/Chicago' + (interval '-1 hours' * ofc.offset)) at time zone 'utc' at time zone 'America/Chicago', 'YYYYMM') to_char((now() at time zone 'utc' at time zone 'America/Chicago' - interval '1' month), 'YYYYMM'))) THEN 'YES' ELSE 'NO' END AS accrual
WHERE
accrual = 'YES'
The problem is there is no table for me to reference the "accrual" column so I get the below error
[Code: 0, SQL State: 42703] ERROR: column "accrual" does not exist
Position: 10708 [Script position: 10708 - 10715]
Asked by zdavis30
(1 rep)
Apr 13, 2021, 06:53 PM
Last activity: Apr 13, 2021, 07:53 PM
Last activity: Apr 13, 2021, 07:53 PM