Hi, I'm translating an app made with visual foxpro and mysql as rdbms to postgres. I've got many querys with this sintax: select code1, sum(if(cond1, price,0)), sum(if(cond2,price,0)) from ... may be it's not sql compliant but very usefull there is a way to do this work on postgres? I can't find any on docs. Thnx, Alejandro
On Fri, Apr 15, 2005 at 09:13:40AM -0300, Alejandro D. Burne wrote: > Hi, I'm translating an app made with visual foxpro and mysql as rdbms > to postgres. > I've got many querys with this sintax: > > select code1, sum(if(cond1, price,0)), sum(if(cond2,price,0)) from ... Use CASE WHEN cond1 THEN price ELSE 0 END. But note that if your condition is to test price for NULL, it's easier to do COALESCE(price, 0) -- Alvaro Herrera (<alvherre[@]dcc.uchile.cl>) "El día que dejes de cambiar dejarás de vivir"
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера