We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You are definitely correct. All the examples I mentioned above do not count the values in a specific column, but rather counts all rows in the GROUP BY regardless of weather certain columns contain null values. I'm simply passing an arbratrary value into the COUNT() function (ie 1 or 'foo') which will count 1 for each row. It is great to point out, as you did, that counting a specific column rather than the row itself will ignore any null values on that column. When you don't care about null values in certain columns, I would avoid passing a specific column into your COUNT() to avoid under-counting due to nulls.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Top Competitors
You are viewing a single comment's thread. Return to all comments →
You are definitely correct. All the examples I mentioned above do not count the values in a specific column, but rather counts all rows in the GROUP BY regardless of weather certain columns contain null values. I'm simply passing an arbratrary value into the COUNT() function (ie 1 or 'foo') which will count 1 for each row. It is great to point out, as you did, that counting a specific column rather than the row itself will ignore any null values on that column. When you don't care about null values in certain columns, I would avoid passing a specific column into your COUNT() to avoid under-counting due to nulls.