Novice to postgresql here. On 8.3 (not my choice, can't do anything about it for near future).
I'm selecting some "time" text strings from a table and inserting them into a view:
create or replace view test as (
select
case
when desc like '%opening%' then 'opening'
when desc like '%closing%' then 'closing'
else n/a
end as time_type,
to_timestamp(time, 'MM/DD/YYYY HH:MI:SS AM') where time_type = 'closing' as closing_time,
to_timestamp(time, 'MM/DD/YYYY HH:MI:SS AM') where time_type = 'opening' as opening_time
from source_table);
I get the error:
ERROR: syntax error at or near "as"
LINE 8: .../YYYY HH:MI:SS AM') where time_type = 'closing' as closing...
I've used this syntax before to create other views so I am confused. Is it because my where statements are incorrectly placed? But if I place them after the from, they will be applied universally, no, and that is not what I want.
WHEREclause in aSELECTstatement.