Discuss the impact of NULL values on aggregate and window functions. How does NULL handling differ, and what precautions should you take?
Last updated
Aggregates like SUM/AVG/MAX skip NULLs, and
COUNT(col)counts only non-NULLs whileCOUNT(*)counts all rows. Ignored is not zero: AVG of {10, NULL} is 10, not 5.Window functions add edge cases:
LAG/LEADreturn NULL past partition edges (give a default), and NULLS FIRST/LAST ordering shifts running totals and ranks.Use COALESCE only when a default is semantically correct, and some engines offer
IGNORE NULLSto skip gaps.
- https://datalemur.com/blog/sql-window-functions-interview-questions
- https://builder.ai2sql.io/blog/sql-window-functions-interview
- https://www.thoughtspot.com/sql-tutorial/sql-window-functions
- https://pipeline2insights.substack.com/p/week-332-advanced-sql-concepts-for
- https://beeclassifieds.beenews.com/story/061/1TW/bE97eV/sql__advanced-interview_questions
- https://medium.com/@aggarwalakshima/interview-question-asked-by-google-and-difference-among-row-number-rank-and-dense-rank-4ca08f888486
- https://www.practicewindowfunctions.com/learn/ranking_functions
- https://www.youtube.com/watch?v=nk8MjpVevsc
- https://sql-academy.org/en/blog/row-number-rank-dense-rank
- https://www.youtube.com/watch?v=GNggtNSz6bw
- https://medium.com/@gankur277/sql-window-functions-explained-with-real-interview-questions-9ab2d44399e6
- https://interviewstack.io/machine_learning_engineer/categories/question-bank/advanced-sql-window-functions-ctes-for-complex-analysis
- https://dev.to/de_clerke/sql-interview-problems-for-data-engineers-30-patterns-that-actually-get-asked-4npk
- https://www.datacamp.com/blog/top-sql-interview-questions-and-answers-for-beginners-and-intermediate-practitioners
- https://www.testgorilla.com/blog/joins-in-sql-interview-questions/
- https://code.likeagirl.io/cte-vs-subquery-vs-recursive-cte-the-interview-question-every-data-scientist-should-know-ce6163487841
- https://www.youtube.com/watch?v=x8wFduXs2kk
- https://medium.com/towards-data-engineering/mastering-sql-recursive-ctes-key-concepts-and-interview-questions-04f69c408e81
- https://learnsql.com/blog/sql-cte-interview-questions/
- https://upesonline.ac.in/blog/advanced-sql-interview-questions
- https://blog.devgenius.io/5-advanced-sql-interview-questions-0b6bcd2f7691
- https://www.red-gate.com/simple-talk/databases/sql-server/t-sql-programming-sql-server/questions-about-cube-rollup-and-grouping-sets-that-you-were-too-shy-to-ask/
- https://towardsdatascience.com/sql-explained-grouping-sets-rollup-and-cube-a097456fb9a2/
- https://www.youtube.com/watch?v=Ccye_H34hBo&vl=en
- https://blog.dailydoseofds.com/p/grouping-sets-rollup-and-cube-in
- https://www.rittmanmead.com/blog/2008/09/cube-rollup-grouping-sets-and-grouping-ids/
- https://blog.stackademic.com/concept-of-pivoting-unpivoting-967ee12a5969
- https://medium.com/geekculture/crack-sql-interview-question-self-join-and-non-equi-join-1cb2a181104a
- https://www.youtube.com/watch?v=k-WQmJWxzTY
- https://learnsql.com/blog/sql-non-equi-joins-examples/
- https://www.datacamp.com/blog/top-sql-joins-interview-questions
- https://thedatamonk.com/advanced-sql-interview-questions/
- https://medium.com/@shankergoud6666/top-50-sql-interview-questions-2026-clear-detailed-answers-to-crack-any-job-275d5d6d3fc9
- https://www.foundit.sg/career-advice/20-common-sql-interview-questions-answers/
- https://www.java-success.com/07-50-sql-scenarios-based-interview-qas-on-pivot-vs-unpivot-case-statements-null-safe-join/
- https://www.datainterview.com/blog/top-100-sql-interview-questions
- https://medium.com/@adichaurasia2611/pivot-and-unpivot-in-sql-explained-simply-91bbf6f49514
- https://www.geeksforgeeks.org/sql/pivot-and-unpivot-in-sql/
- https://www.scaler.com/topics/pivot-in-sql/
- https://grokipedia.com/page/Advanced_SQL_Server_Interview_Questions
- https://www.youtube.com/watch?v=18_cInZr0Gc
- https://medium.com/towards-data-engineering/sql-interview-patterns-003-mastering-gap-islands-with-the-longest-activity-streak-problem-8adeaf7adfb5
- https://medium.com/@mvanshika23/sql-interview-patterns-you-must-know-part-1-n-gaps-and-islands-e9db5c97140f
- https://www.practicewindowfunctions.com/learn/gap_and_island