Re: Return select statement with sql case statement

From: hmidi slim <hmidi(dot)slim2(at)gmail(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Return select statement with sql case statement
Date: 2018-07-04 15:32:36
Message-ID: CAMsqVxsqXZ=DXZrn-gDXgpkGLrFpTpi5Ab2Ky9nKD7Kd1n_uXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Actually, I need the use of case because based on the numberOfPremiumDays
there are different type of treatment:
select numberOfPremiumDays
case when numberOfPremiumDays = date_part('day',
('2018-11-05'::timestamp) - ('2018-11-01'::timestamp)) then
select product_id,
premium_price,
period_price
from product
where occupation_type_id = 1
group by product_id, occupation_type_id
else
select product_id,
classic_price,
period_price
from product1
where occupation_type_id = 1
group by product_id, occupation_type_id

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-07-04 15:49:57 Re: Unable to Connect to DB Instance
Previous Message Andy Colson 2018-07-04 14:38:04 Re: pg_dump out of memory