This uniquely identifies each record in a table.
What is a Primary Key?
Which SQL statement retrieves data from a database?
What is SELECT?
Which function counts the number of rows?
What is COUNT()?
Which JOIN returns only the matching records from both tables?
What is INNER JOIN?
Write an SQL query to display all customer names.
SELECT CustomerName FROM customer_list;
This key creates a relationship between two tables.
What is a Foreign Key?
Which clause filters rows based on a condition?
What is WHERE?
Which function returns the highest value?
What is MAX()?
You have two tables: Students (StudentID, Name) and Enrollments (EnrollmentID, StudentID, Course). Which column should be used to join these tables?
What is StudentID?
Write an SQL query to display the Customer Name and Account Type of every customer.
SELECT c.CustomerName, a.AccountType FROM customer_list c INNER JOIN accounts a ON c.CustomerID = a.CustomerID;
Name the four basic components of a relational database table.
What are tables, records, fields, and keys?
Which SQL command adds a new row to a table?
What is INSERT INTO?
Which clause is used with aggregate functions to organize rows into groups?
What is GROUP BY?
A teacher wants to display all students, including those who have not enrolled in any course. Which JOIN should be used?
What is LEFT JOIN?
Write an SQL query to display Customer Name, Branch Name, Account Type
SELECT c.CustomerName, b.BranchName, a.AccountType
FROM customer_list c INNER JOIN accounts a
ON c.CustomerID = a.CustomerID
INNER JOIN branches b
ON a.BranchID = b.BranchID;
This database rule ensures that every foreign key value must exist in the referenced primary key
What is Referential Integrity?
Which SQL statement modifies the structure of an existing table?
What is ALTER TABLE?
Which clause filters grouped results after GROUP BY?
What is HAVING?
What is missing in this query?
SELECT s.Name, c.CourseName FROM Students s INNER JOIN Courses c
What os ON clause?
Display each branch and the number of accounts opened in that branch.
SELECT b.BranchName, COUNT(a.AccountID) AS TotalAccounts
FROM branches b
INNER JOIN accounts a
ON b.BranchID = a.BranchID
GROUP BY b.BranchName;
A STUDENTS table has StudentID as its primary key. An ENROLLMENT table contains StudentID. What type of key is StudentID in the ENROLLMENT table?
What is a Foreign Key?
Identify the error.
SELECT name age FROM students;
What is the missing comma between name and age?
Which category of functions includes String, Date, and Numeric functions?
What are Scalar Functions?
A LEFT JOIN returns 100 students, but only 80 have enrolled in a subject. How many students will have NULL values in the course columns?
What 20 students?
Display each customer, the number of transactions they made, and the total transaction amount.
SELECT c.CustomerName, COUNT(t.TransactionID) AS TotalTransactions, SUM(t.Amount) AS TotalAmount
FROM customer_list c
INNER JOIN accounts a ON c.CustomerID = a.CustomerID
INNER JOIN transactions t ON a.AccountID = t.AccountID
GROUP BY c.CustomerName;