Unless it's a typo in your email, you probably need a space between '400' and 
'else'. Also make sure the selling price is not a string so the following query 
should work

select count(*) from selling1 where price > 200 and price < 300

Otherwise if they are strings you will need to cast them to numbers to be able 
to use the < and > operators.

hth
charles

On Dec 4, 2010, at 7:45 AM, zhang zhe wrote:

> Hello,
> 
> Does anyone familiar with postgres case statement. 
> 
> I have a tale called selling1.sql, inside table there are two columns
> item(1,1,2,3,3,3,4,4,4....)  and price(234, 243, 245, 342, 124, 245, 343, 
> 123,455.....). I want to select the price where item id is equal to 1, and if 
> its price is bigger than 200 and smaller than 300, the price will be changed 
> into 400 . so in this case, price column value will be changed into,  
> price(400,400, 245,342,124, 245, 343, 123, 455...)
> 
> My sql statement is like this
> 
> select price from selling1 where selling1.item = '1',
>  case when 200<selling1.price and selling1.price <300 then '400'else 'other' 
> END;
> 
> but it always give me the error. It said syntax error in case. 
> 
> Do you known whatś wrong? 
> 
> Thanks
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to