wesleycrusher
Technical User
Here is my code...
CREATE VIEW public.wh AS SELECT DISTINCT model.model_number, model.fuel_type, model.efactor, 41045/model.efactor*365/100000 AS ngas_use, 41045/model.efactor*365/91333 AS pgas_use
FROM
(etc…
I'm trying to determine the annual energy use (represented by ngas_use & pgas_use) of heaters. However, the formula that I use depends on the gas type. So, if the unit uses natural gas, it uses the 100000 formula. If it uses propane, it uses the 91333 formula.
Is there a way to use an if-then type statement in this CREATE VIEW to first determine the fuel_type then employ the appropriate formula to find the annual energy usage? I want to keep the results in two separate columns. TY.
CREATE VIEW public.wh AS SELECT DISTINCT model.model_number, model.fuel_type, model.efactor, 41045/model.efactor*365/100000 AS ngas_use, 41045/model.efactor*365/91333 AS pgas_use
FROM
(etc…
I'm trying to determine the annual energy use (represented by ngas_use & pgas_use) of heaters. However, the formula that I use depends on the gas type. So, if the unit uses natural gas, it uses the 100000 formula. If it uses propane, it uses the 91333 formula.
Is there a way to use an if-then type statement in this CREATE VIEW to first determine the fuel_type then employ the appropriate formula to find the annual energy usage? I want to keep the results in two separate columns. TY.