01.oracle SQL
01.oracle SQL
Introduction
What is Database ? Collection of related data
Employees Departments
Employee number Employee name Department No Department NO Department name Loc
7788 SCOTT 10 10 Accounting Alex
7900 ALEN 20 20 HR Alex
7892 Ward
80 30 Inventory Cairo
40 Purchasing Cairo
8888 Turner 40
What is Table ?
Two dimensional structure consists of rows and columns and used to store data
Chapter01:Writing Basic Select Statement
Introduction
SQL ( Structure Query Language ) Commands
1.Data retrieval Language ( DRL ) Select writing basic select statement
using oracle single row function
using group functions
joining tables
sub-queries
2. Data Manipulation Language ( DML ) - insert
Update
Delete
Merge
3. Data Definition language (DDL) Create
Alter
Drop , Truncate , Rename …
4. Data Control language ( DCL ) Grant , Revoke , Role , Change Password
Chapter01:Writing Basic Select Statement
Chapter Content :
Part1 : Writing Basic Select Statement
Writing Basic Select Statement
Using Arithmetic Operators (Writing Expressions)
Using Alias
Using Concatenation
Using Distinct
Part2: Restricting Rows (Using Where Clause )
Using Comparison Operators
Using In Operator
Using Between and Operator
Using Like Operator
Using Not Operator
Using Multiple Conditions
Part3: Sorting Data
Sorting data by one column
Sorting Data By More Than one Column
Using Alias and Column position in Order By Clause
Chapter01:Writing Basic Select Statement
Chapter Content :
Guide lines
Example :
select *
from emp;
Example :
Desc emp
Introduction to Oracle ERP
1) ()
2) * /
3) + -
Introduction to Oracle ERP
1) ()
2) * /
3) - +
Introduction to Oracle ERP
Practices
In Operator
Value list : Search for Group of Values
Introduction to Oracle ERP
Like Operator
Introduction to Oracle ERP
Like Operator
Introduction to Oracle ERP
Like Operator
Introduction to Oracle ERP
Like Operator
Introduction to Oracle ERP
Like Operator
Introduction to Oracle ERP
Like Operator
Introduction to Oracle ERP
Not
Select *
From emp
Where sal not in ( 800 , 1300 , 3000 ) ;
Introduction to Oracle ERP
Not
Select *
From emp
Where sal not between 2000 and 3000
Introduction to Oracle ERP
Not
Select *
From emp
Where ename not like ‘A%’
Introduction to Oracle ERP
Select *
From emp
Where (deptno = 30 ) and (sal > 2000)
Introduction to Oracle ERP
Select *
From emp
Where (deptno = 30 ) OR (sal > 2000)
Introduction to Oracle ERP
Using Nulls
Introduction to Oracle ERP
Using Nulls
Introduction to Oracle ERP
Sorting Data
Syntax
Select select_list
From table_name
[Where Condition ]
Order by order_by_list
Introduction to Oracle ERP
Sorting Data
Syntax
Select select_list
From table_name
[Where Condition ]
Order by order_by_list
Writing Basic Select St
Sorting Data
Syntax
Select select_list
From table_name
[Where Condition ]
Order by order_by_list
Writing Basic Select St
Sorting Data
Syntax
Select select_list
From table_name
[Where Condition ]
Order by order_by_list
Sorting Data
Syntax
Select select_list
From table_name
[Where Condition ]
Order by order_by_list
Sorting Data
Syntax
Select select_list
From table_name
[Where Condition ]
Order by order_by_list
Practices
1. Write a query to Display Employees Numbers , Names , salaries from emp table
select empno , ename, sal from emp;
2. Write a query to Display Employees with salaries greater than 2000
select * from emp where sal > 2000
3. Write a query to display Employees whose their names start with A
select * from emp where ename like ‘A%’ ;
4. Write a query to display Employees in department 20 , sort your data by salary
select * from emp where deptno = 20 order by deptno ;
5. Write a query to display Employees with these salaries ( 800 , 1300 , 3000 ) sort your data by salary
select * from emp where sal in ( 800 , 1300 , 3000)
6. Write a query to display Employees with Null Commissions sort you data by employee name
Select * from emp where comm is null order by ename
7. Write a query to display Employees work as ANALYST sort your data by deptno
Select * from emp where job =‘ANALYST’ order by deptno ;
8. Write a query to display Employee Hired Before 1990
Practices
1. Write a query to Display Employees Numbers , Names , salaries from emp table
2. Write a query to Display Employees with salaries greater than 2000
3. Write a query to display Employees whose their names start with A
4. Write a query to display Employees in department 20 , sort your data by salary
5. Write a query to display Employees with these salaries ( 800 , 1300 , 3000 ) sort your data by salary
6. Write a query to display Employees with Null Commissions sort you data by employee name
7. Write a query to display Employees work as ANALYST sort your data by deptno
8. Write a query to display Employee Hired Before 1990
9. Write a query to Display employees jobs without duplication
10. Write a query to display employees monthly salary and annual salary name the annual salary column with suitable name
11. Write a query to display employees ( number , name , deptno , sal ) , sort the salary in each department in desc order