KMBN 208 (SQL Queries)
KMBN 208 (SQL Queries)
Unit-3
Creation of Table
Explanation:
Creation of View
A view is a virtual table that provides a way to simplify complex queries, encapsulate data
access, and present data in a specific format.
Suppose we want to create a view to display only the student names and their GPAs.
Creation of Reports
Reports are formatted presentations of data extracted from the database. Reports can be
created using various tools and SQL queries to generate useful information.
Let's create a SQL query to generate a report of students with a GPA above 3.0.
Explanation:
SQL (Structured Query Language) is the standard language for interacting with relational
databases. Below are some basic SQL operations.
Explanation:
Explanation:
Explanation:
UPDATE Students
SET Major = 'Data Science', GPA = 3.8
WHERE StudentID = 1;
Explanation:
Explanation:
Joining Tables
Explanation:
INNER JOIN: Combines rows from two or more tables based on a related column.
ON Students.StudentID = Enrollments.StudentID: Specifies the join condition
between Students and Enrollments.
ON Enrollments.CourseID = Courses.CourseID: Specifies the join condition
between Enrollments and Courses.
Aggregating Data
Explanation:
SELECT AVG(GPA) AS AverageGPA: Calculates the average GPA and assigns an alias
AverageGPA.
FROM Students;: Specifies the table to query data from.