Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window function row_number() result out of order #2620

Closed
blackstar-baba opened this issue Oct 10, 2022 · 0 comments · Fixed by #2999
Closed

Window function row_number() result out of order #2620

blackstar-baba opened this issue Oct 10, 2022 · 0 comments · Fixed by #2999
Labels
Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution

Comments

@blackstar-baba
Copy link
Contributor

Describe the bug

if use order by clause in select sql like this:

select row_number() over(partition by sensorId order by temp),temp,ts from 'readings' where sensorId = 5109 order by temp;

the result out of order

 row_number |        temp        |             ts             
------------+--------------------+----------------------------
        582 | 15.004434478999105 | 2019-11-25 21:29:54.200000
        497 |  15.02493720762422 | 2019-11-20 17:06:55.200000

To reproduce

  1. run this sql
select row_number() over(partition by sensorId order by temp),temp,ts from 'readings' where sensorId = 5109 order by temp;
  1. return result
row_number |        temp        |             ts             
------------+--------------------+----------------------------
        582 | 15.004434478999105 | 2019-11-25 21:29:54.200000
        497 |  15.02493720762422 | 2019-11-20 17:06:55.200000
         28 | 15.027997591584324 | 2019-10-19 07:09:02.300000
         90 | 15.046235126104243 | 2019-10-23 07:44:49.800000
        396 | 15.047976089120429 | 2019-11-14 07:48:38.600000
        573 | 15.052348178001584 | 2019-11-24 21:35:39.700000
         69 | 15.059114960868015 | 2019-10-21 22:11:40.600000
        700 | 15.080164510482806 | 2019-12-04 20:56:32.900000
        727 | 15.081847565313176 | 2019-12-07 06:20:40.500000
        776 | 15.096766057248669 | 2019-12-10 22:21:52.300000
        754 | 15.097841725312733 | 2019-12-08 22:01:43.700000

Expected Behavior

return result

row_number |        temp        |             ts             
------------+--------------------+----------------------------
          0 | 15.004434478999105 | 2019-11-25 21:29:54.200000
          1 |  15.02493720762422 | 2019-11-20 17:06:55.200000
          2 | 15.027997591584324 | 2019-10-19 07:09:02.300000
          3 | 15.046235126104243 | 2019-10-23 07:44:49.800000
          4 | 15.047976089120429 | 2019-11-14 07:48:38.600000
          5 | 15.052348178001584 | 2019-11-24 21:35:39.700000
          6 | 15.059114960868015 | 2019-10-21 22:11:40.600000
          7 | 15.080164510482806 | 2019-12-04 20:56:32.900000
          8 | 15.081847565313176 | 2019-12-07 06:20:40.500000
          9 | 15.096766057248669 | 2019-12-10 22:21:52.300000
         10 | 15.097841725312733 | 2019-12-08 22:01:43.700000
         11 | 15.104586453742463 | 2019-12-19 13:33:19.700000

Environment

- **QuestDB version**: main
- **OS**: MacOS
- **Browser**: Chrome

Additional context

No response

@puzpuzpuz puzpuzpuz added Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution labels Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants