Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2013
    Posts
    19

    Unanswered: Windowing Function Range Between Dates

    Hi,

    How do I write an SQL that will give results based on a moving window based on a date range?
    For e.g. in the following table
    Code:
    KeyCol AmtCol DateCol
    1            10      2013-01-01
    2            20      2013-02-01
    3            30      2013-03-01
    4            40      2013-04-01
    for a given I want to produce the sum of AmtCol between the last month and the next following month.

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Based on what you've written, what would be INPUT (which months, or dates, or what?) and what would be OUTPUT?

    between the last month and the next following month
    I don't understand that. If there's "last month", then it is LAST and there's no "next following month" after that.

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    I was a little disappointed for her(him?) to post in DB2 forum too.
    http://www.dbforums.com/db2/1693559-...een-dates.html

    If (s?)he want to learn SQL more generally, (s)he may want to ask in
    ANSI SQL - dBforums
    Last edited by tonkuma; 06-06-13 at 12:20.

Posting Permissions

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