Add support for parts of the date and time in the clause RANGE window functions
-------------------------------------------------------------------------------

                 Key: CORE-5471
                 URL: http://tracker.firebirdsql.org/browse/CORE-5471
             Project: Firebird Core
          Issue Type: Improvement
            Reporter: Simonov Denis
            Priority: Minor


Currently RANGE clause supports only numeric values for PRECEDING and FOLLOWING 
borders. However, if an expression in the ORDER BY clause is a type of 
TIMESTAMP is difficult to set any interval except for days.

Example 1. Interval - 3 days

select
  bydate,
  total,
  sum(total) over w as s_3days
from sales
window w as (order by bydate range between 3  preceding and current row)

Example 2. Interval - 3 hours

select
  bydate,
  total,
  sum(total) over w as s_3hours
from sales
window w as (order by bydate range between 3 * 1.000 / 24 preceding and current 
row)

The last example is not very beautiful. Oracle Database uses the following 
syntax for time slots.

INTERVAL <expr> {YEAR | MONTH | DAY | HOUR | MINUTE | SECOND}

In this case, the second example would look like this

select
  bydate,
  total,
  sum(total) over w as s_3hours
from sales
window w as (order by bydate range between interval 3 hour preceding and 
current row)







-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to