Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

Postgresql create field from "as " then reuse it but it say does not exist

I create "idprice" field and I want to reuse it is it possible

[Err] ERROR:  column "idprice" does not exist

SELECT
EXTRACT(hour from timestamp8)*100 + EXTRACT(MINUTE from timestamp8) as timest ,
CASE WHEN EXTRACT(hour from timestamp8)*100 + EXTRACT(MINUTE from timestamp8)>=955 and EXTRACT(hour from timestamp8)*100 + EXTRACT(MINUTE from timestamp8)<= 1000  THEN '1'
     WHEN EXTRACT(hour from timestamp8)*100 + EXTRACT(MINUTE from timestamp8)>=1425 and EXTRACT(hour from timestamp8)*100 + EXTRACT(MINUTE from timestamp8)<= 1430  THEN '2'      
     WHEN EXTRACT(hour from timestamp8)*100 + EXTRACT(MINUTE from timestamp8)>=1635 and EXTRACT(hour from timestamp8)*100 + EXTRACT(MINUTE from timestamp8)<= 1640  THEN '3'      
       
       ELSE NULL
       END as idprice ,

CASE WHEN idprice is NULL  THEN '1'
     
       ELSE "Last"
       END as idprice2 ,
"public".pong8_open_price_section.stockid,
"public".pong8_open_price_section.date_hour,

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Teera,
Is this done? If yes, then please select the answer that helped and submit.

Thank you !

Regards,
Pawan