Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
SQL for Data Analytics

You're reading from   SQL for Data Analytics Analyze data effectively, uncover insights and master advanced SQL for real-world applications

Arrow left icon
Product type Paperback
Published in Nov 2025
Publisher Packt
ISBN-13 9781836646259
Length 336 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Authors (5):
Arrow left icon
Jun Shan Jun Shan
Author Profile Icon Jun Shan
Jun Shan
Benjamin Johnston Benjamin Johnston
Author Profile Icon Benjamin Johnston
Benjamin Johnston
Haibin Li Haibin Li
Author Profile Icon Haibin Li
Haibin Li
Matt Goldwasser Matt Goldwasser
Author Profile Icon Matt Goldwasser
Matt Goldwasser
Upom Malik Upom Malik
Author Profile Icon Upom Malik
Upom Malik
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1: Data Management Systems
2. Introduction to Data Management Systems FREE CHAPTER 3. Creating Tables with Solid Structures 4. Exchanging Data Using COPY 5. Manipulating Data with Python 6. Part 2: Data Presentation and Manipulation
7. Presenting Data with SELECT 8. Transforming and Updating Data 9. Defining Datasets from Existing Datasets 10. Aggregating Data with GROUP BY 11. Inter-Row Operation with Window Functions 12. Part 3: Advanced Topics on Analytics
13. Performant SQL 14. Processing JSON and Arrays 15. Advanced Data Types: Date, Text, and Geospatial 16. Inferential Statistics Using SQL 17. A Case Study for Analytics Using SQL 18. Unlock Your Exclusive Benefits 19. Other Books You May Enjoy
20. Index

Creating derived datasets

So far, you have been using SELECT queries to pull data from tables. You may have observed that the results of all SELECT queries are two-dimensional relations that look like the tables in a relational database. Knowing this, you may wonder whether there is some way to use the relations produced by the SELECT queries as if they were tables in your database. The answer is “yes.” You can simply take a query, insert it between a pair of parentheses, and give it an alias. The result of this is a relation that can be used in any other queries. This will help you build an analysis on top of an existing analysis, thus reducing errors and improving efficiency.

To illustrate, look at two tables in the sqlda database—dealerships and salespeople. Both the dealerships table and the salespeople table contain a column called dealership_id. This dealership_id column in the salespeople table is a direct reference to the dealership_id column in the...

lock icon The rest of the chapter is locked
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
SQL for Data Analytics
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 $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon