WEBVTT

00:00.000 --> 00:04.000
Review of SQL Basics

00:04.000 --> 00:07.000
Learning Objectives

00:07.000 --> 00:13.000
Recall and apply basic SQL commands like Select, Wear, Order, Buy and Limit.

00:13.000 --> 00:18.000
Modify data using Insert, Update and Delete safely.

00:18.000 --> 00:26.000
Summarize data using Count, Sum, AVG, MIN, Max, Group Buy and Having.

00:31.000 --> 00:34.000
Core SQL commands

00:34.000 --> 00:39.000
SQL, or Structured Query Language, is how we talk to databases.

00:39.000 --> 00:43.000
The most common command is Select, which fetches data from a table.

00:43.000 --> 00:50.000
For example, Select Star from Students. This shows us every single record.

00:50.000 --> 00:59.000
To filter these results, we use Wear. For example, the Query, Select Star from Students Wear, marks greater than 80.

00:59.000 --> 01:04.000
Retrieves only those students who scored more than 80 marks.

01:04.000 --> 01:11.000
Once we have retrieved the records from the students' table, we can arrange them in a specific order using the Order Buy clause.

01:11.000 --> 01:16.000
In the example shown, the data is sorted based on the Marks column.

01:16.000 --> 01:26.000
The Query, Select from Students Order by Marks ASC, arranges the students in ascending order, displaying them from the lowest marks to the highest.

01:26.000 --> 01:31.000
To keep things manageable, we use Limit command. This shows us just the top three rows.

01:31.000 --> 01:36.000
These core commands are your foundation for finding exactly the data you need.

01:36.000 --> 01:39.000
Data manipulation language

01:39.000 --> 01:44.000
Beyonds just reading data. SQL lets us modify it using DML commands.

01:44.000 --> 01:47.000
We use Insert to add brand new records.

01:47.000 --> 01:53.000
Insert into Students' Values. 6, John 11, 85, 6

01:53.000 --> 01:58.000
This adds a new student named John with Marks 85 in Class 6.

01:58.000 --> 02:02.000
We use Update to change existing data and table.

02:02.000 --> 02:07.000
Update student set Marks equals 85, where ID equals 2.

02:07.000 --> 02:12.000
Here, the marks of the student with ID 2 are updated to 85.

02:12.000 --> 02:17.000
And we use Delete to remove records we don't need from the existing table.

02:17.000 --> 02:20.000
Delete from Students where ID equals 6.

02:20.000 --> 02:24.000
This command deletes the student named John from the table.

02:24.000 --> 02:31.000
But here's the golden rule. Never, ever forget the wear clause in an update or delete.

02:31.000 --> 02:39.000
Without it, you might accidentally change or erase every single record in your table.

02:39.000 --> 02:42.000
Aggregate Functions

02:42.000 --> 02:46.000
SQL is also powerful for summarizing large amounts of information.

02:46.000 --> 02:49.000
We do this with aggregate functions.

02:49.000 --> 02:54.000
The key is the Group by Class ID line, which applies all these functions.

02:54.000 --> 03:01.000
Count, Sum, AVG, Max, and MN, separately to each class group.

03:01.000 --> 03:07.000
In the Select clause, we choose Class.ID, then use Count to get the number of students.

03:07.000 --> 03:12.000
Sum to calculate total marks and AVG for the average.

03:12.000 --> 03:18.000
We also use Max and MIN to find the highest and lowest scores in each class.

03:18.000 --> 03:25.000
Finally, the Having Clause filters the results to show only classes where the average marks are greater than 80,

03:25.000 --> 03:30.000
giving us just the high-performing groups for analysis.

03:33.000 --> 03:36.000
We learned how to retrieve data using Select and Wear.

03:36.000 --> 03:42.000
Organize it with Order Buy and Limit, modify tables using Insert, Update, and Delete,

03:42.000 --> 03:51.000
and summarize information with Count, Sum, AVG, MIN, Max, Group Buy, and Having.

03:51.000 --> 03:56.000
And of course, we saw why using the Wear Clause carefully helps avoid big mistakes.

03:56.000 --> 04:02.000
Master these simple tools and you'll be ready to handle real-world data smartly and safely.

