January 18, 2018 at 10:55 pm
Comments posted to this topic are about the item Basic COUNTs 1
January 18, 2018 at 11:32 pm
Nice simple one to end the week on, thanks Steve.
...
January 19, 2018 at 12:24 am
nice simple. added one condition in my mind while using count() if there is null value will not be calculated...๐๐
Manik
You cannot get to the top by sitting on your bottom.
January 19, 2018 at 1:52 am
'For the DISTINCT keyword, null values are considered to be duplicates of each other. When DISTINCT is included in a SELECT statement, only one NULL is returned in the results, regardless of how many null values are encountered.'
So I guessed 5.
January 19, 2018 at 2:10 am
Nice, easy one to end the week on, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
โlibera tute vulgaris exโ
January 19, 2018 at 5:16 am
paul s-306273 - Friday, January 19, 2018 1:52 AM'For the DISTINCT keyword, null values are considered to be duplicates of each other. When DISTINCT is included in a SELECT statement, only one NULL is returned in the results, regardless of how many null values are encountered.'So I guessed 5.
That's when selecting the values. If you run this code
SELECT DISTINCT charcol
FROM dbo.TheCounts AS tc
you will get 5 lines.
But NULLS are not included in COUNT (nor in other aggregates, like MIN and MAX)
Running the query in the question, you even get a message telling you:
Warning: Null value is eliminated by an aggregate or other SET operation.
January 19, 2018 at 9:20 am
A question I could actually answer! However, after all of the other more difficult questions, I doubted myself. I admit I had to run the code to make sure I wasn't missing anything! Nice discussion about Nulls and how they act with Distinct. I also did not look at the messages tab to see the warning, so that is a good reminder to check that tab!
Thanks!
January 19, 2018 at 5:52 pm
A coffee break question - thank you,. Steve!
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply