Results 1 to 4 of 4

Thread: if sintaxis

  1. #1
    Join Date
    Mar 2003

    Unanswered: if sintaxis

    Can someone tell me how to do the following line:
    SUM(IF(dept = "Development", 1,0)) AS `Development`
    using postgresql sintaxis

  2. #2
    Join Date
    Dec 2002
    Can you describe your query a little bit more? Are you actually just trying to group the sums by department or are you looking to use a conditional within your query?

    Specifically what is this supposed to be doing:
    IF(dept = "Development", 1,0) ?

    If you just want to sum up your rows by department just do a sum on the dept and group by dept.

    If you want to use a conditional check the postgres docs for the CASE function. If you describe your question in more depth I may be able to help a bit more as well.

    (I'm only available at the email address provided in my profile on weekdays, if you have questions or advice, during off hours use AIM). Also any views I provide here or on my website are mine and not representative of any views of my work, family, friends and sometimes even myself.

  3. #3
    Join Date
    Feb 2003

    Re: if sintaxis

    The CASE construct will do the job:
    SUM(CASE dept WHEN 'Development' then 1 else 0 end) AS Development

  4. #4
    Join Date
    Mar 2003

    Thumbs up Re: if sintaxis

    Thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts