Skip to content

Add window functions, PERCENT_RANK(), CUME_DIST() and NTILE().#16

Merged
asfernandes merged 1 commit intoFirebirdSQL:masterfrom
nakagami:new_window_functions
Jun 29, 2016
Merged

Add window functions, PERCENT_RANK(), CUME_DIST() and NTILE().#16
asfernandes merged 1 commit intoFirebirdSQL:masterfrom
nakagami:new_window_functions

Conversation

@asfernandes
Copy link
Copy Markdown
Member

@nakagami I believe it's better to add recordCount to SlidingWindow instead of pass it as win_row_count in winPass method. Next we may see if we can pass SlidingWindow in aggExecute too. Can you please do the first change?

@asfernandes
Copy link
Copy Markdown
Member

@nakagami please let the structure changes for me. But your functions are producing different results than Oracle and PgSQL. Please see this:

create table t (n1 integer);

insert into t values (1);
insert into t values (2);
insert into t values (2);
insert into t values (3);

select n1,
       rank() over (partition by n1 order by n1) r,
       dense_rank() over (partition by n1 order by n1) dr,
       percent_rank() over (partition by n1 order by n1) pr,
       cume_dist() over (partition by n1 order by n1) cd,
       ntile(3) over (partition by n1 order by n1) nt
  from t
  order by n1;

Oracle / PgSQL:

1   1   1   0   1   1
2   1   1   0   1   1
2   1   1   0   1   2
3   1   1   0   1   1

Firebird:

           1                     1                     1       0.000000000000000      0.2500000000000000                     1
           2                     1                     1       0.000000000000000      0.5000000000000000                     1
           2                     1                     1       0.000000000000000      0.5000000000000000                     1
           3                     1                     1       0.000000000000000      0.2500000000000000                     1

@nakagami
Copy link
Copy Markdown
Contributor Author

Sorry I don't have enogh time now. But I will see this issue. Please wait

@asfernandes asfernandes merged commit 8745489 into FirebirdSQL:master Jun 29, 2016
@asfernandes
Copy link
Copy Markdown
Member

I committed this pull request with many changes to fix the mentioned bugs. Please test it.

@nakagami
Copy link
Copy Markdown
Contributor Author

nakagami commented Jun 30, 2016

Oh, sorry and thank you so much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants