Results 1 to 2 of 2

Thread: sql question

  1. #1
    Join Date
    Mar 2002
    Posts
    162

    Unanswered: sql question

    I have a quick question. Hopefully someone will know why .....

    This sql works fine

    SELECT
    'FY 2001 Request' = CASE WHEN (b.ba_nb NOT IN (null,0) AND b.afp_month = '10/1/2001')
    THEN (b.ba_nb) ELSE (CASE WHEN (b.ba_un NOT IN (null,0) AND b.afp_month = '10/1/2001')
    THEN (b.ba_un) ELSE (CASE WHEN (b.ba_py NOT IN (null,0) AND b.afp_month = '10/1/2001')
    THEN (b.ba_py) END) END) END,
    'August AFP' = CASE WHEN (b.ba_nb NOT IN (null,0)) THEN (b.ba_nb) ELSE
    (CASE WHEN (b.ba_un NOT IN (null,0)) THEN (b.ba_un) ELSE
    (CASE WHEN (b.ba_py NOT IN (null,0)) THEN (b.ba_py) END) END) END
    FROM oxb_approved_afp b, oxb_br_code d
    WHERE b.br_key = d.br_key

    but this one doesnt

    SELECT
    'FY 2001 Request' = CASE WHEN (b.ba_nb NOT IN (null,0) AND b.afp_month = '10/1/2001')
    THEN (b.ba_nb) ELSE (CASE WHEN (b.ba_un NOT IN (null,0) AND b.afp_month = '10/1/2001')
    THEN (b.ba_un) ELSE (CASE WHEN (b.ba_py NOT IN (null,0) AND b.afp_month = '10/1/2001')
    THEN (b.ba_py) END) END) END,
    'August AFP' = CASE WHEN (b.ba_nb NOT IN (null,0)) THEN (b.ba_nb) ELSE
    (CASE WHEN (b.ba_un NOT IN (null,0)) THEN (b.ba_un) ELSE
    (CASE WHEN (b.ba_py NOT IN (null,0)) THEN (b.ba_py) END) END) END,
    'Sept Changes' = CASE WHEN (k.ba_nb NOT IN (null,0)) THEN (k.ba_nb) ELSE
    (CASE WHEN (k.ba_un NOT IN (null,0)) THEN (k.ba_un) ELSE
    (CASE WHEN (k.ba_py NOT IN (null,0)) THEN (k.ba_py) END) END) END
    FROM oxb_approved_afp b, oxb_change k ,oxb_br_code d
    WHERE b.br_key = k.br_key
    AND b.br_key = d.br_key

    the only diff is the extra " 'Sept Changes' = CASE WHEN (k.ba_nb NOT IN (null,0)) THEN (k.ba_nb) ELSE
    (CASE WHEN (k.ba_un NOT IN (null,0)) THEN (k.ba_un) ELSE
    (CASE WHEN (k.ba_py NOT IN (null,0)) THEN (k.ba_py) END) END) END"
    and the table name oxb_change k with the extra join.
    anyone see any thing that stands out. The query just sits and does nothing. note br_key is the only primary/foreign key

  2. #2
    Join Date
    Mar 2002
    Posts
    162
    I figured it out. Thanks.

Posting Permissions

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