<html><head><base href="x-msg://1528/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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<div><br></div><div>select count(*) from selling1 where price > 200 and price < 300</div><div><br></div><div>Otherwise if they are strings you will need to cast them to numbers to be able to use the < and > operators.</div><div><br></div><div>hth</div><div>charles</div><div><div><br><div><div>On Dec 4, 2010, at 7:45 AM, zhang zhe wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; ">Hello,<br><br>Does anyone familiar with postgres case statement.<span class="Apple-converted-space"> </span><br><br>I have a tale called selling1.sql, inside table there are two columns<br>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...)<br><br>My sql statement is like this<br><br>select price from selling1 where selling1.item = '1',<br> case when 200<selling1.price and selling1.price <300 then '400'else 'other' END;<br><br>but it always give me the error. It said syntax error in case.<span class="Apple-converted-space"> </span><br><br>Do you known whatÅ› wrong?<span class="Apple-converted-space"> </span><br><br>Thanks<br><br>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></span></blockquote></div><br></div></div></body></html>