January 20, 2015 at 8:47 pm
Comments posted to this topic are about the item COUNT NULLs
January 20, 2015 at 11:44 pm
What does database indicate about nulls being allowed in this table if it is not specified as part of the create table - the insert would fail thus not giving 4 🙂
January 21, 2015 at 12:49 am
Thank you for the post, Steve, nice one.
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
January 21, 2015 at 1:03 am
Nice question. Pretty straightforward after the discussion of the previous COUNT question 😉
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 21, 2015 at 1:04 am
Tony.l (1/20/2015)
What does database indicate about nulls being allowed in this table if it is not specified as part of the create table - the insert would fail thus not giving 4 🙂
Unless explicitly specified, you need to assume SQL Server defaults, which means NULLs are allowed.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 21, 2015 at 2:21 am
This was removed by the editor as SPAM
January 21, 2015 at 3:47 am
Thanx 4 the ez question, which is on the contrary of the 1st Count question.
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
January 21, 2015 at 4:45 am
Nice basic question. thanks for sharing. I assume SQL SERVER default setting discussion wont come in for this QotD but who knows. 🙂
January 21, 2015 at 6:16 am
Koen Verbeeck (1/21/2015)
Tony.l (1/20/2015)
What does database indicate about nulls being allowed in this table if it is not specified as part of the create table - the insert would fail thus not giving 4 🙂Unless explicitly specified, you need to assume SQL Server defaults, which means NULLs are allowed.
Exactly right. Given the previous debate, I think this was a very timely question.
January 21, 2015 at 6:19 am
Hany Helmy (1/21/2015)
Thanx 4 the ez question, which is on the contrary of the 1st Count question.
They aren't contradictory to each other because they were different questions. The debate over the first question is probably why this question was asked. Since the QOTD is about learning, the debate showed a need.
I thought it was easy, but at this moment in time, 76% of the respondents got it right, which means that 24% got it wrong.
January 21, 2015 at 7:27 am
A good (incorrect) alternate answer would be 5. Just to make one think a little harder. 😎
January 21, 2015 at 8:47 am
Easy one for me finally.
January 21, 2015 at 10:21 am
+2 - thanks!
January 21, 2015 at 2:11 pm
Nice question. I've seen some junior developers tripped up by this before.
January 21, 2015 at 2:20 pm
Just though I'd dispel the notion that only count(*) counts nulls:
select count('null') as count_null from (select null n union all select null) countnull
returns:
count_null
2
Gerald Britton, Pluralsight courses
Viewing 15 posts - 1 through 15 (of 28 total)
You must be logged in to reply to this topic. Login to reply