0

I am using CASE to match certain conditions records in table, now in where clause I need to use alias of CASES but it is not allowing, the error shows unknown column monthly_price.

Here is my query:

select 
            (CASE when price > 0 and price < 2000 then (price * 0.05)
            when price > 0 and price <5000 then (price * 1)
            else price
            end)
         as monthly_price,price from qd_posts
         WHERE qd_posts.monthly_price >=0 AND qd_posts.monthly_price <= 5000

I am not sure why it is not allowing.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Bits Please
  • 877
  • 6
  • 23

0 Answers0