Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Write a query to display employee name, join of date, earining ,

comission which is from employee table


select ename,sal,comm,hiredate, from emp;

write a query to display all the details of employee table


select* from emp; * ” * ” (asterick) is wild card character * Here the func-
tionality of the wild card character is to display all the information in the
table. ### Write a query to display all the information of department table
(dept) select* from dept; * here department number is key attribute in this query
* department table is parent table

write a query to display all the details of salgrade table


select* from salgrade; - this is example of primary key is not mandatory but it
is designwise preferrable ### write a query to display all the details of bonus
table select* from bonus; - no rows selecte (since table is there but the data is
not there hence it is showing “no rows seelected”) - It is output and not the error

write a query to display all the table name present in database


select* from tab; (this query shows all the tables present in database)

write a query to display ename sal annual sal which is from etable
**select ename,sal,sal*12 from emp; - here we used sal * 12 - A * B here
asterick is operrand - expression using two or more operrand and combining
some operation to get output it is known as expression.**

write a query to display ename, sal, annual salary, midterm salary,


quarter salary, thousand rupee bonus for monthly commission, 500
rupees deduction for monthly salary which is from emp
select ename,sal,sal12,sal6,sal3,comm+1000,sal-500 from emp; ### write
a query to display ename, sal, job, annual sal, midterm sal, 1000 rs bonus
for annual sal, 500 rs deduction for midterm sal which is from emp select
ename,sal,job,sal12,sal6,sal12+1000,sal*6-500 from emp;

write a query to display ename,sal, annual sal, 10% incriment for


monthly sal which is from emp
select ename,sal,sal12,sal10/100 or select ename,sal,sal12,sal1.1 or select
ename,sal,sal12,sal +sal0.1

write a query to display ename, sal, annual sal, 20 % decrement for


monthly salary, 10 % increment for monthly comm
select ename,sal,sal12,sal-sal0.2,comm*1.1

1
write a query to display ename,sal,annual sal, 10% incriment for
midterm sal
select ename,sal,sal12,sal6+sal60.1

write a qurery to display ename sal annual sal midterm sal 28% in-
crement for annual sal
10% decrement for midterm comm
select ename,sal,sal12,sal6+sal60.28,comm-comm0.1

Write a query to display ename sal 15% increment for quarter sal and
15%decrement for midterm sal
select ename,sal,sal3+sal30.15,sal6-sal60.15

write a query to display ename sal from emp


select ename,sal from emp;

write a query to display unique salary form employee table


select sal from emp;

distinct : it is a keyword used to avoid duplicate data at the time of


execution.

Difference between Unique and Distinct


unique is a constraint which is used to avoid duplicate data but distinct is a
keyword which used to display the unique data at time of execution
Distinct removes the duplicate that is already entered into the column whereas
unique avoids the data to be entered into the column
unique is DDL and distinct is DQL
Unique is used to define the data but distict is used to query (remove ) the data

write a query to display unique job present in emp


select distinct(job) from emp; ### write a query to display unique department
number present in emp
select distinct(deptno) from emp;

write a query to display annual salary 15% decrement for quarter sal.
select ename,sal,sal12,sal12+sal*0.15 from emp;

2
Alias Name
It is an alternate name given to the column or expression at the time of execution.
Syntax : how to give alias name ways to write alias name
sal12 annual sal6 “midtermsal” sal*6 midtermsal ename as empname

write a query to display ename annual sal 30% incriment for midterm
commission and 10% decrement for monthly sal (provide some suit-
able alias name)
select ename as empname,comm6+comm60.3 as midterm_commission_incriment,sal-
sal0.1 as decrement_for_monthly_sal from emp; ## selection statement
retrival of data from the table while providing both column name and row
name
Where clause It is a clause used to filter the records or it is a clause used to
filter the condition row by row ## Characteristics of where clause - where
clause executes row by row - where clause executes after the execution of from
clause - where clause can take multiple condition - in where clause we can’t write
multirow function - this mulitrow funciton is a new topic - **path of execution -
from clause then where clause and then select clause - Characteristics of where
clause ### Write a query to display ename sal job if the ename is smith
select ename,sal,job from emp where ename=‘SMITH’; sql statements is not
case sensitive, data is case sensitive.

write a query to display ename deptno if the employees are working


in department number 10
select ename,deptno from emp where deptno=10;

LIST ALL THE EMPLOYEES WHOSE COMMISSION IS NULL


SELECT ename FROM emp WHERE comm is NULL;

LIST ALL THE EMPLOYEES WHO DON’T HAVE A REPORTING


MANAGER.
select ename from emp where mgr is NULL;

You might also like