March 8, 2010 at 8:11 pm
Gosh, I'm the FIRST person to answer this QotD!
Thanks for the questions Prakriti.
S.
March 8, 2010 at 10:20 pm
I read up what is the definition of count_big before I answered half-blindly. I never used it before and I may use it only years from now, since our transactional data is still too far from 2 billion rows (int, 4 bytes).
But thanks anyway.
*edited - our table with highest number of rows is still too far from even 10 million.
March 9, 2010 at 12:16 am
Maybe this is a bit nitpicky, but the answer explanation doesn't seem to match the answer.
The answers are: SELECT COUNT_BIG(*) and SELECT COUNT_BIG(column_2).
This sentence does not match the correct answers. It seems somewhat confusing and could create a bit of a stir.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 9, 2010 at 12:34 am
I too had to look up COUNT_BIG in BOL since i wasn't even aware it existed. So thanks for the question, I learned something new yet again. Still got the answer wrong though. I realized a split second after clicking the Answer button that the point was gone 🙁
March 9, 2010 at 12:51 am
CirquedeSQLeil (3/9/2010)
The answers are: SELECT COUNT_BIG(*) and SELECT COUNT_BIG(column_2).
This sentence does not match the correct answers. It seems somewhat confusing and could create a bit of a stir.
This is wiered...I answered II and III, thereby getting both correct?
SELECT COUNT_BIG(column_2)
SELECT COUNT_BIG(ALL column_2)
ALL is the default and hence COUNT_BIG(column 2) is same as COUNT_BIG(ALL column_2). This evaluates expression for each row in a group and returns the number of nonnull values.
Maybe the first paragraph of the explanation was wrong?
The answers are: SELECT COUNT_BIG(*) and SELECT COUNT_BIG(column_2). COUNT_BIG(*) will count all rows from the table (including duplicate & null rows). COUNT_BIG(DISTINCT column_2) will evaluate distinct non-null values.
If the correct answers are different from mine, it's alright for me to have my points deducted. I know I will never be able to verify the answers without wrecking my server's disk space or processing power.
March 9, 2010 at 1:35 am
Thanks for the question..hurray I got it correct...but only after reading explanation about it in BOL...I never heard about it before...but its a very useful function...
Yes..the explanation given by OP was wrong..answer II and III is absolutely correct.
March 9, 2010 at 1:43 am
Thanks for the question. Learn something new today.
March 9, 2010 at 2:04 am
Great question, made you think about the simple functions that we take for granted, even though i have never needed to use count_big
March 9, 2010 at 3:13 am
the answer is I and II , not II and III.
does anyone audit these questions? i want my point (joke) 🙂
March 9, 2010 at 3:22 am
i think you are incorrect as from this simple example script (im using sql2005)
declare @t table(i int, x int)
insert into @t
select 1, null
union
select 3, 1
union
select 2, 1
select *
from @t
select count_big(*)
from @t
select count_big(x)
from @t
it shows that count_big ignored the nulls in the second query
March 9, 2010 at 4:25 am
I answered I and II and according to the explanation, it should be right. I need my point, I'm only on Grasshopper status! Need points... 🙂
March 9, 2010 at 6:47 am
I too got it wrong because I needed a refresher regarding the evil side of NULL.
Good QotD - Thanks
March 9, 2010 at 6:52 am
Good question - Thought that I knew the answer, and was wrong. Now, I have a question. I ran the following against an existing database to prove/disprove the answer, and found the following:
SELECT COUNT_BIG(*) FROM test_table
98481
SELECT COUNT_BIG(testfield2) FROM test_table
98481
SELECT COUNT_BIG(ALL testfield2) FROM test_table
98481
SELECT COUNT_BIG(DISTINCT testfield2) FROM test_table
28452
Based upon testing, though brief, and the answer, I would assume that the correct answer is 1, 2, and 3. The answer description states that ALL is the default, whether used or not thus selection 1 would use the default of ALL as shown in the above example, correct?
Steve Jimmo
Sr DBA
“If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
March 9, 2010 at 6:57 am
Explaination is a little off.
COUNT_BIG(all column_2) will count all rows from the table (including duplicate & null rows).
I think you meant count_big(*). COUNT_BIG(all column_2) will not count the NULLs.
Viewing 15 posts - 1 through 15 (of 45 total)
You must be logged in to reply to this topic. Login to reply