GROUP BY returns 1 invalid result if no rows meet condition
See original GitHub issueIf there is a query that has no results, but contains a GROUP BY, it returns one result regardless, with the data of “undefined”
console.log(alasql('SELECT Name FROM ? WHERE 1=0 GROUP BY Name',[[{Name:'test'}]]));
returns: [{Name: 'undefined'}] but should be []
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
GROUP BY returns 1 invalid result if no rows meet condition #79
Another issue with GROUP BY is that any field in the result that is not in the group is 'undefined'. MySQL simply returns...
Read more >Select No Rows If Any Row Meets A Condition? - Stack Overflow
Something like this ? SELECT * FROM SOMETABLE WHERE ID = 1 AND NOT EXISTS (SELECT 1 FROM SOMETABLE WHERE INDICATOR = 'X')....
Read more >7 Common GROUP BY Errors - LearnSQL.com
1. Forgetting GROUP BY with Aggregate Functions. You use SELECT statements with the GROUP BY clause when you want to group and organize...
Read more >Select rows within group before condition is met
A single window function in a subquery should do the trick: SELECT * FROM ( SELECT *, count(*) FILTER (WHERE height = 0)...
Read more >Possible Wrong Results of the Group By Clause - SQLite Forum
Should not it returns two rows or zero row? ... sqlite> select * from t2 group by 1; -- unique values in column...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
adding HAVING count(*) > 0 seems to fix this problem
Well… its now returning
[{}]
instead of the original problem - but its still not correct.Any help to resolve this would be awesome.
http://jsfiddle.net/t780pnz1/