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

The result of query ends up with 'null' values with keywords: ORDER BY and LIMIT #1965

Open
daviddabingu opened this issue Aug 22, 2024 · 0 comments

Comments

@daviddabingu
Copy link

I've been trying to build this test app where user uploads csv file and then run SQL queries.
This is the SQL query.

`
SELECT [subcategoryname], SUM([totalamount]) AS sales
FROM temptable
GROUP BY [subcategoryname]
ORDER BY sales DESC
LIMIT 3

UNION ALL

SELECT [subcategoryname], SUM([totalamount]) AS sales
FROM temptable
GROUP BY [subcategoryname]
ORDER BY sales ASC
LIMIT 3;
`

As you can see here, what I tried to do was to get top/bottom 3 of SUM([[totalamount]) from the table, using UNION ALL.
However, what I've got returned follows: only three rows, where 2 containing 'null' sales value.
My assumption here was that ORDER BY somehow includes null values when sorting.

image


AlaSQL is based on unpaid voluntary work. Thank you for taking the time to make it better.

Got ChatGPT?


Question about how to...


Something is not working as expected:

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

No branches or pull requests

1 participant