avatarNaina Chaturvedi

Summary

The provided content outlines Day 5 of a 15-day advanced SQL series, focusing on wildcards, aggregation, and sequences in SQL, and offers resources for further learning in system design, data structures, algorithms, and various tech projects.

Abstract

The web content is part of an educational series on advanced SQL topics, currently on its fifth day. It introduces the concepts of wildcards in SQL, which are used for pattern matching within data, and elaborates on the use of the percent sign (%) and underscore (_) as wildcard characters. The content also covers aggregation in SQL, explaining how functions like COUNT, SUM, AVG, MIN, and MAX can be used to perform calculations across multiple rows and summarize data. Additionally, the article discusses the use of sequences in SQL for generating unique integers, typically used for primary keys. The author provides SQL syntax examples and implementation snippets to illustrate these concepts. Beyond Day 5's focus, the content previews the next day's topic and links to a comprehensive repository for advanced SQL learning materials. It also promotes a YouTube channel for project and coding exercise videos and lists additional resources for system design, data structures, algorithms, and tech projects, encouraging readers to subscribe for more updates and information.

Opinions

  • The author believes that understanding wildcards, aggregation, and sequences is crucial for advanced SQL proficiency.
  • They emphasize the importance of practical examples and provide code snippets to reinforce learning.
  • The author values the community aspect of learning, suggesting readers engage through comments, likes, and subscriptions.
  • They highlight the importance of a well-rounded tech education by providing links to a variety of related topics and series beyond SQL.
  • The author is enthusiastic about sharing knowledge and encourages readers to follow their educational journey for continued growth in tech skills.
  • They assert that the provided resources and educational series can help readers become proficient in advanced SQL and other tech domains.

Day 5 of 15 Days of Advanced SQL Series

Pic credits : noise

Welcome back peeps. Hope all’s well. Last two weeks have been crazy busy at work for me (plus I was traveling).

Day 1 : SQL Basics and Kick start of Advanced SQL Series

Day 2 : SQL Basics, Query Structure, Built In functions Conditions

Day 3 : Most Important Commands, Joins and Filters

Day 4 : Set Theory Operations, Stored Procedures and CASE statements in SQL

Day 5 : Wildcards, Aggregation and Sequences in SQL

Day 6 : Subqueries, Group by, order by and Having clauses in SQL and Analytical Functions

Day 7 : Window Functions, Grouping Sets and Constraints in SQL

Day 8 : BigQuery Basics, SELECT, FROM, WHERE and Date and Extract in BigQuery

Day 9 : Common Expression Table, UNNEST Clause, SQL vs NoSQL Databases

Day 10 : Triggers, Pivot and Cursors in SQL

Day 11 : Views, Indexes and Auto Increment in SQL

Day 12 : Query optimizations, Performance tuning in SQL

Day 13 : Introduction to MySQL, PostgreSQL and Mongo DB, Comparison between MySQL and PostgreSQL and Mongo DB, Introduction to SQL and NoSQL Databases

Day 14 : MySQL in Depth

Day 15 : PostgreSQL inDepth

Anyways, For day 5 of 15 days of Advanced SQL, we will cover —

Wildcards in SQL

Aggregation in SQL

Sequences in SQL

Github for Advanced SQL that you can follow —

Projects Videos —

All the projects, data structures, SQL, algorithms, system design, Data Science and ML , Data Analytics, Data Engineering, , Implemented Data Science and ML projects, Implemented Data Engineering Projects, Implemented Deep Learning Projects, Implemented Machine Learning Ops Projects, Implemented Time Series Analysis and Forecasting Projects, Implemented Applied Machine Learning Projects, Implemented Tensorflow and Keras Projects, Implemented PyTorch Projects, Implemented Scikit Learn Projects, Implemented Big Data Projects, Implemented Cloud Machine Learning Projects, Implemented Neural Networks Projects, Implemented OpenCV Projects,Complete ML Research Papers Summarized, Implemented Data Analytics projects, Implemented Data Visualization Projects, Implemented Data Mining Projects, Implemented Natural Leaning Processing Projects, MLOps and Deep Learning, Applied Machine Learning with Projects Series, PyTorch with Projects Series, Tensorflow and Keras with Projects Series, Scikit Learn Series with Projects, Time Series Analysis and Forecasting with Projects Series, ML System Design Case Studies Series videos will be published on our youtube channel ( just launched).

Subscribe today!

System Design Case Studies — In Depth

Design Instagram

Design Messenger App

Design Twitter

Design URL Shortener

Design Dropbox

Design Youtube

Design API Rate Limiter

Design Web Crawler

Design Facebook’s Newsfeed

Design Yelp

Design Uber

Design Tinder

Design Tiktok

Design Whatsapp

Most Popular System Design Questions

Mega Compilation : Solved System Design Case studies

Complete Data Structures and Algorithm Series

Complexity Analysis

Backtracking

Sliding Window

Greedy Technique

Two pointer Technique

Arrays

Linked List

Strings

Stack

Queues

Hash Table/Hashing

Binary Search

1- D Dynamic Programming

Divide and Conquer Technique

Recursion

Github —

Let’s get started with Day 5.

  • Wildcards in SQL are used to search for data in a column that matches a certain pattern. The two most commonly used wildcards are the percent sign (%), which represents zero or more characters, and the underscore (_), which represents a single character.
  • Aggregation in SQL is the process of combining data from multiple rows into a single result. Common aggregate functions include COUNT, SUM, AVG, MIN, and MAX. These functions are typically used in conjunction with a GROUP BY clause to group the data by one or more columns.
  • Sequences in SQL are used to generate unique integers. They are often used to generate primary key values for tables. Common functions used to work with sequences include NEXTVAL and CURRVAL. The specific syntax for using sequences may vary depending on the SQL database management system being used.

Wildcards in SQL

It is used to search for a pattern/data within a table and these characters ( listed below) are used with the LIKE operator.

% means any character with any number of count

? means any single character

*means one or more characters

[] means one value within the specified limit in the square brackets

\ means it matches the character that follows the backslash

^ means all character except [^characters]

-means range of characters within the brackets [characters]

Format —

SELECT * FROM table_name WHERE column_name LIKE ‘%ny%’

SELECT * FROM table_name WHERE column_name LIKE ‘_ewyork’

SELECT * FROM table_name WHERE column_name LIKE ‘_e_yo_k’

SELECT * FROM table_name WHERE column_name LIKE ‘[n-y]%’

SELECT * FROM table_name WHERE column_name LIKE ‘[adf]%’

Implementation —

-- Example: Get all employees whose names start with 'J'
SELECT *
FROM Employees
WHERE EmployeeName LIKE 'J%';

-- Example: Get all employees whose names end with 'son'
SELECT *
FROM Employees
WHERE EmployeeName LIKE '%son';

-- Example: Get all employees whose names contain 'doe' in any position
SELECT *
FROM Employees
WHERE EmployeeName LIKE '%doe%';

-- Example: Get all employees whose names have 'a' as the second character
SELECT *
FROM Employees
WHERE EmployeeName LIKE '_a%';

-- Example: Get all employees whose names have 'in' at the third and fourth position
SELECT *
FROM Employees
WHERE EmployeeName LIKE '__in%';

-- Example: Get all employees whose names start with 'A', 'B', or 'C'
SELECT *
FROM Employees
WHERE EmployeeName LIKE '[A-C]%';

-- Example: Get all employees whose names contain either 'a' or 'e'
SELECT *
FROM Employees
WHERE EmployeeName LIKE '%[ae]%';

-- Example: Get all employees whose names do not contain 'x'
SELECT *
FROM Employees
WHERE EmployeeName LIKE '%[^x]%';

-- Example: Get all employees whose names start with any character except 'A', 'B', or 'C'
SELECT *
FROM Employees
WHERE EmployeeName LIKE '[^A-C]%';

Snippet —

Aggregation in SQL

It’s used to perform calculation on mutiple rows/values and return a single result as the answer. It ignores NULL values when performing aggregation.

Some of the most important aggregate functions are —

  • COUNT() — To count the number of rows
  • SUM() — To return sum of the column
  • AVG ()— To return average of the column
  • MIN() — To return min value in the column
  • MAX() — To return max value in the column

Format —

Count(column_name)

Sum(column_name)

Avg(column_name)

Min(column_name)

Max(column_name)

Example —

SELECT COUNT(employee_id)

FROM employee_table

WHERE salary > 40000

SELECT MAX(salary)

FROM employee_table

SELECT MIN(salary)

FROM employee_table

SELECT AVG(salary)

FROM employee_table

SELECT SUM(salary)

FROM employee_table

Implementation —

-- Example: Get the total number of employees
SELECT COUNT(*) AS TotalEmployees
FROM Employees;

-- Example: Get the sum of salaries for all employees
SELECT SUM(Salary) AS TotalSalary
FROM Employees;

-- Example: Get the average salary of employees
SELECT AVG(Salary) AS AverageSalary
FROM Employees;

-- Example: Get the minimum and maximum salary of employees
SELECT MIN(Salary) AS MinSalary, MAX(Salary) AS MaxSalary
FROM Employees;

Sequences in SQL

Sequences are very useful to identify each row of the table with a unique key in the form of a numerical series for the data which doesnt have unique identifiers/keys.

Format —

CREATE SEQUENCE sequence_name

START WITH initialize

INCREMENT BY increment_value

MINVALUE min_value

MAXVALUE max_value

CYCLE or NOCYCLE

Example —

CREATE SEQUENCE sequence64

START WITH 12

INCREMENT BY 2

MINVALUE 10

MAXVALUE 98

CYCLE;

Implementation —

-- Create a sequence
CREATE SEQUENCE sequence_name
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 1000
    CYCLE;

-- Use the sequence to generate values
INSERT INTO table_name (id, column1, column2)
VALUES (NEXTVAL('sequence_name'), value1, value2);

-- Retrieve the next value from the sequence
SELECT NEXTVAL('sequence_name');

-- Reset the sequence to its initial value
ALTER SEQUENCE sequence_name RESTART;

That’s it for now.

Find Day 6 Below —

Let me know if you have questions in the comment section below. Subscribe/ Follow, Like/Clap as it would encourage me to write more in my free time

Stay Tuned!!

Read More —

11 most important System Design Base Concepts

1. System design basics

2. Horizontal and vertical scaling

3. Load balancing and Message queues

4. High level design and low level design, Consistent Hashing, Monolithic and Microservices architecture

5. Caching, Indexing, Proxies

6. Networking, How Browsers work, Content Network Delivery ( CDN)

7. Database Sharding, CAP Theorem, Database schema Design

8. Concurrency, API, Components + OOP + Abstraction

9. Estimation and Planning, Performance

10. Map Reduce, Patterns and Microservices

11. SQL vs NoSQL and Cloud

12. Most Popular System Design Questions

13. System Design Template — How to solve any System Design Question

14. Quick RoundUp : Solved System Design Case Studies

Some of the other best Series —

60 days of Data Science and ML Series with projects

30 Days of Natural Language Processing ( NLP) Series

30 days of Machine Learning Ops

30 days of Data Structures and Algorithms and System Design Simplified

60 Days of Deep Learning with Projects Series

30 days of Data Engineering with projects Series

Data Science and Machine Learning Research ( papers) Simplified **

100 days : Your Data Science and Machine Learning Degree Series with projects

23 Data Science Techniques You Should Know

Tech Interview Series — Curated List of coding questions

Complete System Design with most popular Questions Series

Complete Data Visualization and Pre-processing Series with projects

Complete Python Series with Projects

Complete Advanced Python Series with Projects

Kaggle Best Notebooks that will teach you the most

Complete Developers Guide to Git

Exceptional Github Repos — Part 1

Exceptional Github Repos — Part 2

All the Data Science and Machine Learning Resources

210 Machine Learning Projects

Tech Newsletter —

If you are interested, you can join my newsletter through which I send tech interview tips, techniques, patterns, hacks — Software Development, ML, Data Science, Startups and Technology projects to more than 30K readers. You can subscribe to Tech Brew :

For Python Projects —

For complete 60 days of Data Science and ML : Day 1 — Day 60 : Quick Recap of 60 days of Data Science and ML

Follow for more updates. Stay tuned and keep coding!

For other projects, tune to —

Build Machine Learning Pipelines( With Code)

Recurrent Neural Network with Keras

Clustering Geolocation Data in Python using DBSCAN and K-Means

Facial Expression Recognition using Keras

Hyperparameter Tuning with Keras Tuner

Custom Layers in Keras

Software Development
Tech
Data Science
Machine Learning
Programming
Recommended from ReadMedium