Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Data Wrangling with SQL

You're reading from  Data Wrangling with SQL

Product type Book
Published in Jul 2023
Publisher Packt
ISBN-13 9781837630028
Pages 350 pages
Edition 1st Edition
Languages
Authors (2):
Raghav Kandarpa Raghav Kandarpa
Profile icon Raghav Kandarpa
Shivangi Saxena Shivangi Saxena
Profile icon Shivangi Saxena
View More author details

Table of Contents (21) Chapters

Preface 1. Part 1:Data Wrangling Introduction
2. Chapter 1: Database Introduction 3. Chapter 2: Data Profiling and Preparation before Data Wrangling 4. Part 2:Data Wrangling Techniques Using SQL
5. Chapter 3: Data Wrangling on String Data Types 6. Chapter 4: Data Wrangling on the DATE Data Type 7. Chapter 5: Handling NULL Values 8. Chapter 6: Pivoting Data Using SQL 9. Part 3:SQL Subqueries, Aggregate And Window Functions
10. Chapter 7: Subqueries and CTEs 11. Chapter 8: Aggregate Functions 12. Chapter 9: SQL Window Functions 13. Part 4:Optimizing Query Performance
14. Chapter 10: Optimizing Query Performance 15. Part 5:Data Science And Wrangling
16. Chapter 11: Descriptive Statistics with SQL 17. Chapter 12: Time Series with SQL 18. Chapter 13: Outlier Detection 19. Index 20. Other Books You May Enjoy

Calculating descriptive statistics with SQL

Calculating descriptive statistics with SQL is an important topic in data analysis, as it allows us to summarize and understand the main characteristics of a dataset. Here are some examples of how to calculate various measures of central tendency and variability in SQL.

Mean

The mean, also known as the average, is a measure of central tendency that represents the sum of all values in a dataset divided by the number of observations. In SQL, we can calculate the mean using the AVG() function. For example, to calculate the mean of the salary column in the employees table, we can use the following query:

SELECT AVG(salary) AS mean_salaryFROM employees;

Case scenario

An interesting real-world scenario for calculating the mean in SQL for descriptive statistics is to analyze the average time spent by visitors on a website. Assume we have a table named pageviews containing records of page views with columns such as visitor_id, page_url...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}