4. SQL - Data Query Language Upto Normal Operators
4. SQL - Data Query Language Upto Normal Operators
WELCOME TO
SQL SESSION
Address
SELECT
PROJECTION
SELECTION
JOINS
9606060871 / 9606060872
ARC Technologies & Institutions DATA QUERY LANGUAGE
2) PROJECTION : Retrieval Of The Data From The Table By Selecting Column Name Is Known As Projection.
3) SELECTION : Retrieval Of Data From The Table By Selecting Column Name As Well As Row Name Is Known As Selection.
4) JOINS : Retrieval Of The Data From The Multiple Tables Simultaneously Is Known As Joins
Example 1 : Select Ename from Emp ; Example 2 : Select Ename,MGR from Emp ; Example 3 : Select EMPNO,Ename,SAL from Emp ;
9606060871 / 9606060872
ARC Technologies & Institutions SELECT
Question 1 : WAQTD All The Employee Name From The Employee Table.
Query : Select Ename
From Employee;
Note : * (Asterisk/Wild Character) : it Is Used To Select All The Details From The Given Table
Question 6 : WAQTD All The Department Name From The Department Table.
Query : Select Dname
From Department;
Question 7 : WAQTD Location From Department Table.
Query : Select Location
From Department;
9606060871 / 9606060872
ARC Technologies & Institutions SELECT
Question 10 : WAQTD All The Department Number Along With Commission From Employee Table.
Query : Select Deptno, comm
From Employee;
Question 11 : WAQTD Designation Along With Salary And Also Display Employee Name.
Query : Select Job, sal, ename
From Employee;
Question 12 : WAQTD All The Employee Names Along With Monthly Salary.
Query : Select Ename, sal
From Employee;
Question 13 : WAQTD Employee Number ,Employee Name , Job Also Salary Along With Annual Salary.
Query : Select Empno, ename, job, sal, sal*12
From Employee;
Expressions
9606060871 / 9606060872
ARC Technologies & Institutions EXPRESSION
Definition : Anything Which Gives Results Or Output Is Known As An Expression
10 + 10 10 / 10
Operators Operators
9606060871 / 9606060872
ARC Technologies & Institutions EXPRESSION
Question 2 : WAQTD Employee Number And Manager Number Along With Annual Commission
Question 5 : WAQTD Employee Name Along With 18% Hike Given To The Monthly Commission But 5% Deduction In Annual Salary.
Question 7 : WAQTD Job, Monthly Salary, Along With 12% Hike Given To Monthly Salary From Employee
Table.
Question 8 : WAQTD Employee Name , Monthly Salary And Annual Salary Also Display 28% Hike Given Annual
Salary.
9606060871 / 9606060872
ARC Technologies & Institutions ALIAS NAME
Definition : It Is An Alternative Name Given To The Column Name Or An Expression Which Is Present In Resultant Table.
Conditions To Write Alias Name : 1) With Or Without Using The Keyword 'As' We Can Write Alias Name.
2) If We Are Using Multiple Words As Alias Name Than It Has To Be Enclosed It
Within " " Or We Can Join Them Using Underscore( _ ).
9606060871 / 9606060872
ARC Technologies & Institutions ALIAS NAME
Question 2 : WAQTD Job And Hiredate As Date Of Joining From Employee Table.
Question 3 : WAQTD Employee Name Along With 25% Deduction In Monthly Salary.
9606060871 / 9606060872
ARC Technologies & Institutions DISTINCT
Definition : It Is Used To Avoid Duplicate Records Which Are Present In Resultant Table.
Note : 1) Always Distinct Should Be The 1st Argument To The Select Clause.
2) We Can Pass Multiple Argument To The Distinct Clause.
3) Distinct Will Remove The Combination Of Columns Which Are Duplicate.
Query : Select Distinct Deptno Query : Select Distinct Job,deptno Query : Select Distinct Job
From Employee; From Employee; From Employee;
Result : JOB DEPTNO
Result : DEPTNO
CLERK 20 JOB
10 SALESMAN 30 CLERK
20 MANAGER 20
SALESMAN
MANAGER 30
30 MANAGER
MANAGER 10
ANALYST 20 ANALYST
PRESIDENT 10 PRESIDENT
CLERK 30
CLERK 10
9606060871 / 9606060872
ARC Technologies & Institutions DISTINCT
Question 1 : WAQTD Employee Number And Manager Number And Salary With Incentive Of 200.
Query : Select *
From Employee;
Question 4 : WAQTD All The Details Of Employee Along With Annual Salary.
Definition : Retrieval Of Data From The Table By Selecting Column Name As Well As Row Name Is Known As Selection.
9606060871 / 9606060872
ARC Technologies & Institutions SELECTION
Question 1 : WAQTD Employee Name And Salary Of Employee Where Name Is King.
Query : Select Ename,sal
From Employee
Where Ename='king';
Question 2 : WAQTD Name And Job ,Department Number If Employees Are Working In Dept Number 20.
Query : Select Ename,job,deptno
From Employee
Where Deptno=20;
Question 3 : WAQTD Name And Salary Given To All Employee If Employees Are Getting Salary More Than 1600.
Query : Select Ename,sal
From Employee
Where Sal>1600;
Question 4 : WAQTD All The Details Of Employee Except Who Are Working As Salesman
Query : Select *
From Employee
Where Job!='Salesman';
Note : Not Equal Operator (!=) OR (<>)
9606060871 / 9606060872
ARC Technologies & Institutions SELECTION
Question 5 : WAQTD Employee Number ,Commission Along With Name If Employee Are Getting Comm Less Than 1500.
Query : Select Empno,comm,ename
From Employee
Where Comm<1500;
Question 6 : WAQTD Employee Number ,Salary Of Employee Whose Employee Number Is 7788
Query : Select Empno,sal
From Employee
Where Empno=7788;
Note : Note Equal Operator (!=) OR (<>)
Question 7 : WAQTD Details Of Employee Who Are Not Working In Dept 30.
Query : Select *
From Employee
Where Deptno != 30;
Question 8 : WAQTD All The Details Of Employee Along With Annual Salary Of All The Employee Except Clerk.
Query : Select Emp.*,Sal*12
From Employee
Where Job<>'clerk';
9606060871 / 9606060872
ARC Technologies & Institutions DISTINCT
9606060871 / 9606060872