Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008

    Unanswered: SQL query to extract DB2data

    Hi i have a query
    select 12 * int( "SQLUSER"."BTT120".yyyy) + int("SQLUSER"."BTT120".mm) as actual,
    12*year(CURRENT DATE) + month(CURRENT DATE) as ending,
    12*year(CURRENT DATE) + month(CURRENT DATE)-3 as starting
    from "SQLUSER"."BTT120"
    where "SQLUSER"."BTT120".yyyy ='2007' and "SQLUSER"."BTT120".mm in ('10','11','12')

    which gives me ourput

    Actual ending Starting
    24094 24097 24094

    My actual requirment is to get the data for the rolling 3 months for which i used the same logic as above in the WHERE clause.

    where (12 * int( "SQLUSER"."BTT120".yyyy)) + int("SQLUSER"."BTT120".mm) between
    (12*year(CURRENT DATE)) + month(CURRENT DATE)-3 and
    (12*year(CURRENT DATE)) + month(CURRENT DATE)

    everything looks good but iam not getting output, there is data for the date range

    (12 * int( "SQLUSER"."BTT120".yyyy)) + int("SQLUSER"."BTT120".mm) = 24094
    (12*year(CURRENT DATE)) + month(CURRENT DATE)-3 = 24094
    (12*year(CURRENT DATE)) + month(CURRENT DATE) = 24097

    can anyone help me if iam wrong in syntax. new to DB2


  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    i would suggest you try a DB2 message board. The one DB2 guy who frequents this board has been MIA for a few days. Probably skiing.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

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