FoDB - Lab 3
FoDB - Lab 3
• SELECT statement
• The FROM clause
• WHERE clause and SQL Operators
• GROUP BY clause
• HAVING clause
• ORDER BY clause
• Aggregate Functions
• Example … :
– SELECT DEPARTMENT_NAME,LOCATION_ID FROM
DEPARTMENTS;
– SELECT DISTINCT job_id FROM employees;
• Retrieves unique job_id value
– SELECT * FROM EMPLOYEES;
• * is used to refer to all attributes of the table
– SELECT employee_id "Emp #", last_name
"Employee",job_id "Job", hire_date "Hire
Date‚ FROM employees;
– SELECT last_name
FROM employees
WHERE last_name LIKE 'a%'
AND last_name LIKE '%e%';
-- retrieves those whose last name
begins with an a and contains ‘e’ in it.
• Display the last name, job, and salary for all employees
whose job is either that of a sales representative or a
stock clerk, and whose salary is not equal to $2,500,
$3,500, or $7,000
• Example: ..
– SELECT department_id, AVG(salary)
FROM employees
GROUP BY department_id ;
FROM employees
WHERE manager_id IS NOT NULL
GROUP BY manager_id
HAVING MIN(salary) > 6000
ORDER BY MIN(salary) DESC;
-- displays the manager number and the salary of the lowest-paid
employee for that manager. Exclude any groups where the
minimum salary is $6,000 or less
-- The HAVING clause is used to specify conditions after grouping