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

Strange behavior of count(*) over () #5189

Closed
brankoradovanovic-mcom opened this issue Dec 29, 2024 · 0 comments
Closed

Strange behavior of count(*) over () #5189

brankoradovanovic-mcom opened this issue Dec 29, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@brankoradovanovic-mcom
Copy link

Details

Certain SQL statements using count(*) over () return wrong results. Strangely, I couldn't reproduce this behavior in other SQLite environments. I've also tried it with:

Steps to reproduce

create table test as select 1 as x union all select 2;

--Q1
select *, count(*) over () as cnt
from test;

--Q2
select *, count(*) over () as cnt
from (select * from test);

Q1 returns:

x cnt
1 2
2 2

...which is as expected, but Q2 returns:

x cnt
1 1
2 2

...which is wrong. The expected result of Q2 is the same as Q1, of course.

My first thought was that it had to be an SQLite bug, but I couldn't reproduce it anywhere else, as noted above. I'm not sure if the use of an SQL window function is relevant to the problem or not.

Operating system

Windows 10 Pro x64

SQLiteStudio version

3.4.13

@pawelsalawa pawelsalawa added this to the 3.4.14 milestone Dec 29, 2024
@pawelsalawa pawelsalawa added the bug Something isn't working label Dec 29, 2024
pawelsalawa added a commit that referenced this issue Jan 14, 2025
…AR operator for result columns (in these subselects), so they return correct results.; Fixed execution of complex SELECT queries with subselects, that join multiple tables, some with aliases, some without aliases. Results from such queries would not be editable at all. Now they execute properly using the Smart Execution method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants