Hour_2_SQL_Basics_Practice_Updated
Hour_2_SQL_Basics_Practice_Updated
1. SELECT Statement
Syntax: SELECT column1, column2 FROM table_name;
Examples:
1. SELECT first_name, last_name FROM employees;
Explanation: Retrieves the first and last names of all employees from the
employees table.
2. SELECT department_id FROM departments;
Explanation: Retrieves all department IDs from the departments table.
3. SELECT * FROM employees;
Explanation: Retrieves all columns and rows from the employees table.
4. SELECT salary FROM employees;
Explanation: Retrieves the salary column for all employees.
5. SELECT first_name || ' ' || last_name AS full_name FROM employees;
Explanation: Combines first name and last name with a space to form a full
name and renames the column as "full_name".
6. SELECT DISTINCT job_id FROM employees;
Explanation: Retrieves unique job IDs from the employees table.
7. SELECT COUNT(*) FROM employees;
Explanation: Counts the total number of employees in the employees table.
8. SELECT first_name, salary * 12 AS annual_salary FROM employees;
Explanation: Calculates annual salary by multiplying monthly salary by 12 and
renames the column as "annual_salary".
9. SELECT SYSDATE FROM dual;
Explanation: Retrieves the current date and time from the system.
10. SELECT 'Hello, Oracle SQL!' FROM dual;
Explanation: Outputs a static string "Hello, Oracle SQL!".