Basic Statistics in SQL: Average, Median, Percentiles and Standard Deviation
Calculate averages, medians, percentiles, mode and standard deviation in SQL Server and MySQL, find outliers, and learn which number to report.
Calculate averages, medians, percentiles, mode and standard deviation in SQL Server and MySQL, find outliers, and learn which number to report.
How to get the latest record or the top N rows for each group in SQL Server with ROW_NUMBER(), handle ties correctly, and when CROSS APPLY or WITH TIES is the better choice.
How to calculate a running total and a running account balance in SQL Server with SUM() OVER, reset it per month or account, and avoid the two mistakes that give wrong or slow results.
A beginner-friendly guide to SQL window functions: OVER, PARTITION BY, ROW_NUMBER, RANK, running totals and LAG, with clear examples.