SQL Foundations Flashcards
(41 cards)
What does SQL stand for?
Structured Query Language
What is a database?
An organized collection of data stored and accessed electronically
What SQL command is used to retrieve data?
SELECT
What SQL keyword is used to remove duplicate values?
DISTINCT
How do you select all columns from a table named employees?
SELECT * FROM employees;
What SQL clause filters rows based on a condition?
WHERE
How do you retrieve employees with a salary greater than 50000?
SELECT * FROM employees WHERE salary > 50000;
What is the purpose of the ORDER BY clause?
To sort the results by one or more columns
How do you sort results by name in descending order?
ORDER BY name DESC
What is the default sort order for ORDER BY?
Ascending (ASC)
What clause is used to group rows that have the same values?
GROUP BY
How do you find the number of employees in each department?
SELECT department
What function calculates the number of rows?
COUNT()
What function returns the average value of a column?
AVG()
What function returns the largest value?
MAX()
What function returns the smallest value?
MIN()
What function returns the sum of values in a column?
SUM()
What SQL clause filters groups created by GROUP BY?
HAVING
What is the difference between WHERE and HAVING?
WHERE filters rows before grouping; HAVING filters groups after grouping
What SQL statement is used to insert data?
INSERT INTO
How do you insert a row into a table?
INSERT INTO table_name (column1
What statement modifies existing data?
UPDATE
How do you update the salary of an employee with ID 3?
UPDATE employees SET salary = new_value WHERE id = 3;
What command deletes rows from a table?
DELETE