Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Posts
    16

    Arrow Unanswered: any provision for writing conditional queries

    does postgresql provides any support for writing 'C' language case syntax in query.
    my problem is that i want a cumulative figure that is sum of the numeric figures feeded between a two dates or for the specified month based on a condition.
    is it possible for me to write in a single query
    Last edited by itsvasu; 04-17-03 at 03:07.

  2. #2
    Join Date
    Mar 2003
    Posts
    16
    i got the partial solution

    SELECT * FROM test;
    a
    ---
    1
    2
    3

    => SELECT a,
    CASE WHEN a=1 THEN 'one'
    WHEN a=2 THEN 'two'
    ELSE 'other'
    END
    FROM test;
    a | case
    ---+-------
    1 | one
    2 | two
    3 | other


    i expected case in where condition
    but it seems the correct one

    :-)

  3. #3
    Join Date
    Apr 2003
    Location
    MN
    Posts
    9

    just a idea

    Would a stored proc maybe do the trick if you can't accomplish this is strainght SQL??

Posting Permissions

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