getCountQuery doesn't respect distinct flag
See original GitHub issueIt seems our getCountQuery
implementation doesn’t respect the distinct
flag i.e. it should construct a count(distinct ...)
for the select list in that case. Also, it can’t work when group by and distinct
are combined.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to count distinct flags in the sql - Stack Overflow
You can use conditional aggregation. SELECT Category, COUNT(DISTINCT CASE WHEN Flag = 1 THEN PERSON END) FROM MYGROUP GROUP BY Category;.
Read more >Overview of the SQL Count Distinct Function - SQLShack
This article explores SQL Count Distinct operator for eliminating the duplicate rows in the result set. A developer needs to get data from...
Read more >DAX measure to find distinct count of flags set to '1' and '0'
Hi Experts, I have a table say employee which has a attendance flag say flag set to 1 or 0 stating whether they...
Read more >HAVING clause of GROUP BY. - Ask TOM
Hi Tom,Recently I came across a query with the following text:SELECT bbl1. ... key from ttest group by key having count(distinct flag) =...
Read more >Using Self Joins To Calculate Your Retention, Churn, And ...
This is tricky in SQL, which doesn't have explicit ways to bucket users ... user_id from events ) select this_month.month, count(distinct user_id) from ......
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
Thanks for testing! I think these cases are covered by the following testsuite methods:
testCountWithHavingClauseThatCannotBeExpressedAsWhereClause
is covered bycom.blazebit.persistence.testsuite.CountQueryTest#countQueryFromHavingQuery
testCountWithGroupByClauseThatCannotBeRemoved
is covered bycom.blazebit.persistence.testsuite.CountQueryTest#countQueryWithGroupBy
testCountDistinctWithGroupByClauseThatCannotBeRemoved
is covered bycom.blazebit.persistence.testsuite.CountQueryTest#countQueryWithDistinct
I’ve just done a couple of tests in
CountQueryTest
against the currentmaster
, and they all worked flawlessly.The scenario’s I’ve tested:
My scenario’s were as follows, if you’re interested in any of them let me know, then I’ll provide them as patch. 👍 I wasn’t sure for which of these scenarios tests already exist.