Lab 07 - SQL (DML)-02
Lab 07 - SQL (DML)-02
• UPDATE table_name
SET column1 = value1, column2 = value2, ..
.
WHERE condition;
• Example:
• update employees set first_name='Ali',
last_name='Jaber', email='[email protected]'
where employee_id=199;
The SQL DELETE Statement
• The DELETE statement is used to delete
existing records in a table.
• Example:
– delete from employees where employee_id=199;
ROWNUM Clause
• The ROWNUM Clause is used to specify the
number of records to return.
• SELECT column_name(s)
FROM table_name
WHERE ROWNUM <= number;
ROWNUM Clause Examples
• select * from employees where
rownum<=10;
• SELECT MIN(column_name)
FROM table_name
WHERE condition;
MIN() & MAX Examples
• select min(salary) as minimum_salary from employees;
MINIMUM_SALARY
--------------
2100
COUNT(*)
----------
4
The SQL GROUP BY Statement
• The GROUP BY statement is often used with aggregate
functions (COUNT, MAX, MIN, SUM, AVG) to group the
result-set by one or more columns.
• SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...
);
• SELECT column_name(s)
FROM table_name
WHERE column_name IN (SELECT STATEMENT);
The SQL BETWEEN Operator
• The BETWEEN operator selects values within a
given range. The values can be numbers, text,
or dates.
• SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1
AND value2;
SQL Aliases
• SQL aliases are used to give a table, or a column in a table, a
temporary name.
• SELECT column_name(s)
FROM table_name AS alias_name;
User Prompt
You can write any thing else here but it should not contain spaces and & is required here