SlideShare a Scribd company logo
1 of 14
Download to read offline
1) Answer the following queries based on the given table:EMP NO. ENAME

JOB

SALARY

DEPT.NO.

7680

SCOTT

MANAGER

20,000

10

7688

JACK

CLERK

5,000

20

7454

MACK

ANALYST

2,000

10

7210

BEN

MANAGER

20,000

30

7621

MARTIN

SALESMAN

15,000

40

a) Write a query to display the list of employee with salary.
Ans:- select ename ,sal
fromemp;
b) Write a query to display all the records of employee table.
Ans:- select empno,ename,job,sal , dept no
fromemp;
c) Write a query to display the name of employee along with designation &
salary.
Ans:- select ename,job,sal
fromemp;
d) Write a query to display the list of employees who get salary more than
10,000.
Ans:- select ename
fromemp
wheresal> 10,000;
e) Write a query to display all records of dept no. 10.
Ans:- select* from emp where dept no=10;
2) Table 1.2 shows the records of a shop named customers. Give the query to
the questions asked based on the table.
CUST NO.

NAME

AMOUNT(RS/-) PRODUCT

101

ALKA

20

MAGGI

509

SURESH

467

KISSAN JAM

01

MAHIMA

945

PULSES

240

DECK

1,000

RICE

109

HEENA

45

MACRONI

a) Write a query to display all the records of purchase of pulses product.
Ans:- select* from customer
where product=`pulses’;
b) Write a query to display the total sales(in terms of rupee). Total
sales=amount * 20
Ans:- select amount * 20 “total sales”
from customer;
c) Write a query to display the name of customers with product whose
name starts from H and ends with A.
Ans:- select name,product
from customer
where namelike`H%A’ ;
d) Write a query to display all the records of cust no.109
Ans:- select* from customer
wherecust no=109 ;
3) Write sql commands for the following on the basis of the table student.

STUDENT
NO.

CLASS

NAME

GAME

GRADE 1

SUPW

10

7

SAMEER

CRICKET

B

PHOTOGRAPHY A

11

8

SUJIT

TENNIS

A

GARDENING

12

7

KAMAL

SWIMMING

B

PHOTOGRAPHY B

13

7

VEENA

TENNIS

C

COOKING

A

14

9

ARCHANA

BASKET BALL

A

LITERATURE

A

15

10

ARPIT

CRICKET

A

GARDENING

C

GRADE 2

C

a) Display the name of the students who are getting a grade `c’ in either game
or supw.
Ans:- select name from student
whereGrade 1 =`C’ or Grade 2 = `C’ ;
b) Display the different games offered in the school.
Ans:- select distinct (Game)
from student;
c) Display the SUPW taken up by the students whose name starts with `A’.
Ans:- select SUPW from student
where name LIKE `A%’;
4) Write sql commands for the following on the basis of the given table CLUB.
COACH- ID

COACH NAME

AGE

SPOERTS

DATE OF APP

PAY

SEX

1

KUKREJA

34

KARATE

27/3/1996

1000

M

2

RAVINA

34

KARATE

20/01/1998

1200

F

3

KARAN

34

SQUASH

19/02/1998

2000

M

4

TARUN

33

BASKETBALL

01/01/1998

1500

M

5

ZUBIN

36

SWIMMING

12/01/1998

750

M

6

KETAKI

36

SWIMMING

24/02/1998

800

F

7

ANKITA

39

SQUASH

20/02/1998

2200

F

8

ZAREEN

37

KARATE

22.02/1998

1100

F

9

KUSH

41

SWIMMING

13/01/1998

900

M

10

SHAILYA

37

BASKETBALL

19/02/1998

1700

M

a) To show all the information about the swimming coaches in the club.
Ans:- select* from club
where sports=`SWIMMING’;
b) To list the names of all coaches with their date of appointment
(date of app) in descending order.
Ans:- select COACH NAME, DATE OF APP from club
order by DATE OF APP desc;
c) To display a report, showing coachname, pay, age & bonus (15% of pay)
for all the coaches.
Ans:- select COACHNAME,PAY,AGE,P*15 “BONUS”
from club;
5) Write sql commands for the following on the basis of the given table
STUDENT 1.
NO NAME

STIPEND

STREAM

AVG. MARKS GRADE CLASS

1

KARAN

400.00

MEDICAL

78.5

B

12B

2

DIVAKAR

450.00

COMMERCE

89.2

A

11C

3

DIVYA

300.00

COMMERCE

68.6

C

12C

4

ARUN

350.00

HUMANITIES

73.1

B

12C

5

SABINA

500.00

NON-MEDICAL

90.6

A

11A

6

JOHN

400.00

MEDICAL

75.4

B

12B

7

ROBERT

250.00

HUMANITIES

64.4

C

11A

8

RUBINA

450.00

NON-MEDICAL

88.5

A

12A

9

VIKAS

500.00

NON-MEDICAL

92.0

A

12A

10

MOHAN

300.00

COMMERCE

67.5

C

12C

a) select all the numerical stream students from STUDENT 1.
Ans:- select name,stream from STUDENT 1
where stream= `non-medical’;
b) list all name os those students who are in class 12 sorted by stepend.
Ans:- select name from STUDENT 1
where class LIKE `12-’
Order By stipend;
c) list all students stored by average marks in descending order.
Ans:- select name from STUDENT 1
Order by avg. marks DESC;
d) display a report, listing name, stipend,stream& amount of stipend received
in a year assuming that the stipend is paid every month.
Ans:- select name,stipend * 12,stream from STUDENT1 ;
6) Write sql commands for the following on the basis of given table LIBRARY.
NO. TITLE

AUTHOR

TYPE

PUB

QUANTITY PRICE

1

DATA STRUCTURE

LIPSCHUTZ

DS

MC GRAW

4

217

2

COMPUTER STUDIES

FRENCH

FND

GALGOTIA

2

75

3

ADVANCE PASCAL

SCHILDT

PROG

MC GRAW

4

350

4

DBASE DUMMIES

PALMER

DBMS

PUSTALE M

5

130

5

MASTERING C++

GWEWICH

PROG

BPB

3

295

6

GUIDE NETWORK

FREED

NET

Z PRESS

3

200

7

MASTERING FOXPRO

SEIGAL

BDMS

BPB

2

135

8

DOS GUIDE

MORTON

OS

PHI

3

175

9

BASIC FOR BEGINNERS

MORTON

PROG

BPB

3

40

10

MASTERING WINDOWS

COWARD

OS

BPB

1

225

a) Select all the PROG type published by BPB from library.
Ans:- select* from library
where type= `PROG’AND PUB= `BPB’ ;
b) Display a list of all books with price more than 130&sDrted by qty.
Ans:- select* from library
where price>130
Order by qty;
c) Display all the books sorted by price in ascending order.
Ans:- select* from library
Order by price ASCE;
7) Write
NO. TITLE

sql commands for the following on the basis of the given table MOV.
TYPE
RATING STARS
QTY.
PRICE

1

GONE WITH THE WIND

DRAMA

G

GABLE

4

39.95

2

FRIDAY THE 13th

HORROW

R

JASON

2

69.95

3

TOP GUN

DRAMA

PG

CRUISE

7

49.95

4

SPLASH

COMEDY

PG13

HANKS

3

29.95

5

INDEPENDENT DAY

DRAMA

R

TURNER

3

19.95

6

RISKY BUSINESS

COMEDY

R

CRUISE

2

44.95

7

COCOON

SCIFI

PG

AMECHE

2

31.95

8

CROCODILE DUNDEE

COMEDY

PG13

HARRIS

2

69.95

9

101 DALMATIANS

COMEDY

G

PATTINSON

3

59.95

10

TOOTSIE

COMEDY

PG

HOFFMAN

1

29.95

a) Display a list of all movies with price over 20 & sorted by price
Ans :- select Title , price from MOV
where price >20
Order by price;
b) Display all the movies sorted by QTYin decreasing order
Ans :- select *from MOV
Order by qty DESC;
c) Display a report listing a movie number , current value & replacement
value for each movie in the given table. Calculate the replacement value
for all the movies as aty*price*1.15.
Ans:- select no., price,qty.*price*1.15
from MOV
Group by no;
8) Write

sql commands for the following on the basis of the given table
GRADUATE.
S.NO. NAME

STIPEND SUBJECT

AVERAGE RANK

1

KARAN

400

PHYSICS

68

1

2

DIVAKAR

450

COMPUTER SCIENCE

68

1

3

DIVYA

300

CHEMISTRY

62

2

4

ARUN

350

PHYSICS

63

1

5

SABINA

500

MATHEMATICS

70

1

6

JPHN

400

CHEMISTRY

55

2

7

ROBERT

250

PHYSICS

64

1

8

RUBINA

450

MATHEMATICS

68

1

9

VIKAS

500

COMPUTER SCIENCE

62

1

10

MOHAN

300

MATHEMATICS

57

2

a) List the names of those students who have obtained rank 1 by NAME.
Ans:- select NAME from graduate
where rank=`1’
Order by NAME;
b) Display a report listing NAME,STIPEND,SUBJECT& amount of stipend
received in a year assuming that the STIPEND is paid every month.
Ans:- select NAME, STIPEND,SUBJECT,STIPEND * 12
from GRADUATE;
9) Write sql commands for the following on the basis of the given table
Teacher.
NO. NAME

AGE DEPARTMENT

DATE OF JOIN

SALARY

SEX

1

JUGAL

34

COMPUTER

10/01/97

12000

M

2

SHARMILA

31

HISTORY

24/03/98

20000

F

3

SANDEP

32

MATHS

12/12/96

30000

M

4

SANGEETA

35

HISTORY

01/07/99

40000

F

5

RAKESH

42

MATHS

05/09/97

25000

M

6

SHYAM

50

HISTORY

27/06/98

30000

M

7

SHIV OM

44

COMPUTER

25/02/97

21000

M

8

SHALAKHA

33

MATHS

31/07/97

20000

F

a) To show all information about the teacher of history department.
Ans:- select* from teacher
where Department=`HISTORY’;
b) To list the names of female teachers who are in mathsdepartment.
Ans:- select name from teacher
where department=`MATHS’ AND sex=`F’;
c) To list the names of all teachers with their date of joining in ascending
order.
Ans:- select Name, Date of join
from teacher
Order by Date of join ASC;
10)

Write a query to create table student having following
specifications:Column name type
size
constraint
Sname

char

40

Cls

int

>6

Marks

number

2,2

unique

default

Ans:-Create table student
( sid number primary key,
sname char(40) unique,
clsint check(cls.6),
marks number(2,2) default=12);

11)

Write a query to create table customer having following
specifications:Column name type
size
constraint
Cno.

Number

3

Name

varchar

10

Amount

Float

-

>5000

comn

Number

-

Default=1001

A ns:- Create table customer
( cno number(3) primary key,
name varchar(10),
amount float check(amount>5000),
comn number default=1001);

Primary
12)

Write a query to create table ITEM

Column name

type

Item no.

Number

Item name

Varchar

40

Amount

Number

4,2

Qty.

number

Ans:- create table Item
(
Item no number primary,
Inamevarchar(40),
Amount number(4,2),
Qty number check (qty>100)
);

size

constraint
primary

>100
13)

Write queries based on the following table PET.

NAME

OWNER

SPECIES

SEX

BIRTH

DEATH

FLUFFY

HAROLD

CAT

F

4/2/1993

NULL

CLAWS

GWEN

CAT

M

17/3/1994

NULL

BUFFY

HAROLD

DOG

F

13/5/1989

NULL

FANG

BENNY

DOG

M

27/8/1990

NULL

BROWSER

DIANE

DOG

M

31/8/1979

29/7/1995

EHIRPY

GWEN

BIRD

F

11/9/1998

NULL

WHISTLER

GWEN

BIRD

NULL

9/12/1997

NULL

SLIM

BENNY

SNAKE

M

29/4/1996

NULL

PUFFBALL

DIANE

HAMSTER

F

30/3/199

NULL

a) Display all the details from PET table for species cat/dog having gender
(sex )as male(`M’).
Ans:-select* from PET
where (species=`cat’||specie=`dog’) &&
sex=`m’;
b) Display all details of pet of species bird,snake or hamster from table PET
Ans:- select* from PET
where species in (`bird’,`snake’,`hamster’);
c) Display the names of pets who are no more.
Ans:- select name from PET
where death IS NOT NULL;
14)

Consider the table EXAM given.Write commands in mysql.

NO NAME

STIPEND

SUBJECT

AVG.

DIVISION

1

KARAN

400

ENGLISH

68

FIRST

2

AMAN

680

MATHS

72

FIRST

3

JAVED

500

ACOUNTS

67

FIRST

4

BISHAKH

200

INFORMATICS

55

SECOND

5

SUGANDHA

400

HISTORY

35

THIRD

6

SUPARNA

550

GEOGRAPHY

45

THIRD

a) To list the names of those students, who have obtained division as FIRST
in the ascending order of NAME.
b)
Ans:- select name,division from EXAM
where division=`FIRST’
Order by NAME ASC;
c) To display a report listing name, subject, annual stipend received
assuming that the stipend column has monthly stipend.
Ans: select name, stpend,subject * 12 from EXAM;
d) To count the number of students who have either accounts or
informatics as subject.
Ans:- select name from EXAM
where subject=`Accounts’ or subject=`Informatics’;
15)

Write sql commands based on the given table EMPL.

EMP
NO

ENAME

JOB

MGR.

HIREDATE

SAL

COMM.

8369

SMITH

CLERK

8902

18/12/1990

800

NULL

8499

ANYA

SALESMAN

8698

4/2/1990

1600

300

8521

SETH

MANAGER

8698

18/7/1991

2000

500

8566

MAHADEVAN SALESMAN

8839

30/4/1990

400

NULL

8698

MOMIN

CLERK

NULL

28/6/1992

7800

1400

8888

BEENA

ANALYST

8854

4/8/1990

2000

NULL

8900

AMIR

CLERK

6478

4/4/1991

1100

NULL

8844

KULDEEP

PRESIDENT

8522

8/9/1999

5000

0.00

a) Cunt number of records in table employee.
Ans:-select count(*) “Total”

b)

c)

d)

e)

from EMPL;
Count number of jobs in table EMPL.
Ans:- select count(job) “job count “
from EMPL;
How many distinct jobs are listed in the table EMPL.
Ans:- select count(distinct job) “distict jobs”
from EMPL;
Display max. salary from the table EMPL.
Ans:- select max(sal) “maximum salary”
from EMPL;
Display the joining date of senior most employee.
Ans:- select MIN (hiredate) “minimum hiredate”
From EMPL;

More Related Content

What's hot (20)

Sql queires
Sql queiresSql queires
Sql queires
 
SQL practice questions set - 2
SQL practice questions set - 2SQL practice questions set - 2
SQL practice questions set - 2
 
All questions
All questionsAll questions
All questions
 
SQL BASIC QUERIES
SQL  BASIC QUERIES SQL  BASIC QUERIES
SQL BASIC QUERIES
 
Sql operator
Sql operatorSql operator
Sql operator
 
Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4
 
Sql task
Sql taskSql task
Sql task
 
Complex queries in sql
Complex queries in sqlComplex queries in sql
Complex queries in sql
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinct
 
Q on subquery
Q on subqueryQ on subquery
Q on subquery
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3
 
SQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONSQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTION
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
Dump Answers
Dump AnswersDump Answers
Dump Answers
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Aggregate function
Aggregate functionAggregate function
Aggregate function
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
Sql queries
Sql queriesSql queries
Sql queries
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
Sql queries interview questions
Sql queries interview questionsSql queries interview questions
Sql queries interview questions
 

Viewers also liked

Structured query language
Structured query languageStructured query language
Structured query languageanujchouksey
 
JAVA AND MYSQL QUERIES
JAVA AND MYSQL QUERIES JAVA AND MYSQL QUERIES
JAVA AND MYSQL QUERIES Aditya Shah
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Aman Deep
 
CBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationCBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationGuru Ji
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
 

Viewers also liked (12)

Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
Structured query language
Structured query languageStructured query language
Structured query language
 
Sql
SqlSql
Sql
 
Dbms new manual
Dbms new manualDbms new manual
Dbms new manual
 
JAVA AND MYSQL QUERIES
JAVA AND MYSQL QUERIES JAVA AND MYSQL QUERIES
JAVA AND MYSQL QUERIES
 
1 z0 047
1 z0 0471 z0 047
1 z0 047
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
Sql queries
Sql queriesSql queries
Sql queries
 
DBMS Practical File
DBMS Practical FileDBMS Practical File
DBMS Practical File
 
CBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationCBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL Presentation
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 

Similar to SQL QUERIES FOR EMPLOYEE TABLE

Oracle (SQL), Sulieman Khudruj
Oracle (SQL), Sulieman KhudrujOracle (SQL), Sulieman Khudruj
Oracle (SQL), Sulieman KhudrujSulieman Khudruj
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresConnor McDonald
 
90 Informatics Practices.pdf
90 Informatics Practices.pdf90 Informatics Practices.pdf
90 Informatics Practices.pdfvikas500500
 
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.pptUnit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.pptIronMan665214
 
Row patternmatching12ctech14
Row patternmatching12ctech14Row patternmatching12ctech14
Row patternmatching12ctech14stewashton
 
Sample Paper Class XI (Informatics Practices)
Sample Paper Class XI (Informatics Practices)Sample Paper Class XI (Informatics Practices)
Sample Paper Class XI (Informatics Practices)Poonam Chopra
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresConnor McDonald
 
Pre-Calculus Midterm Exam 1 Score ______ ____.docx
Pre-Calculus Midterm Exam  1  Score ______  ____.docxPre-Calculus Midterm Exam  1  Score ______  ____.docx
Pre-Calculus Midterm Exam 1 Score ______ ____.docxChantellPantoja184
 
BUSINESS STATISTICS IMPORTANT QUESTIONS LIST
BUSINESS STATISTICS IMPORTANT QUESTIONS LISTBUSINESS STATISTICS IMPORTANT QUESTIONS LIST
BUSINESS STATISTICS IMPORTANT QUESTIONS LISTRAJASEKHAR REDDY
 
Math primar primary 3 المراجعة النهائية لنصف العام
Math primar primary 3 المراجعة النهائية لنصف العام Math primar primary 3 المراجعة النهائية لنصف العام
Math primar primary 3 المراجعة النهائية لنصف العام أمنية وجدى
 

Similar to SQL QUERIES FOR EMPLOYEE TABLE (20)

DBMS Lab
DBMS LabDBMS Lab
DBMS Lab
 
Ip xi iii_ut_14-15
Ip xi iii_ut_14-15Ip xi iii_ut_14-15
Ip xi iii_ut_14-15
 
Oracle (SQL), Sulieman Khudruj
Oracle (SQL), Sulieman KhudrujOracle (SQL), Sulieman Khudruj
Oracle (SQL), Sulieman Khudruj
 
c language programing
c language programing c language programing
c language programing
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL features
 
Cs practical file
Cs practical fileCs practical file
Cs practical file
 
Excel assignment
Excel assignmentExcel assignment
Excel assignment
 
Excel assignment
Excel assignmentExcel assignment
Excel assignment
 
solDocument
solDocumentsolDocument
solDocument
 
90 Informatics Practices.pdf
90 Informatics Practices.pdf90 Informatics Practices.pdf
90 Informatics Practices.pdf
 
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.pptUnit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
 
Row patternmatching12ctech14
Row patternmatching12ctech14Row patternmatching12ctech14
Row patternmatching12ctech14
 
Sample Paper Class XI (Informatics Practices)
Sample Paper Class XI (Informatics Practices)Sample Paper Class XI (Informatics Practices)
Sample Paper Class XI (Informatics Practices)
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL features
 
Pre-Calculus Midterm Exam 1 Score ______ ____.docx
Pre-Calculus Midterm Exam  1  Score ______  ____.docxPre-Calculus Midterm Exam  1  Score ______  ____.docx
Pre-Calculus Midterm Exam 1 Score ______ ____.docx
 
Cp unit 3
Cp unit 3Cp unit 3
Cp unit 3
 
BUSINESS STATISTICS IMPORTANT QUESTIONS LIST
BUSINESS STATISTICS IMPORTANT QUESTIONS LISTBUSINESS STATISTICS IMPORTANT QUESTIONS LIST
BUSINESS STATISTICS IMPORTANT QUESTIONS LIST
 
Math primar primary 3 المراجعة النهائية لنصف العام
Math primar primary 3 المراجعة النهائية لنصف العام Math primar primary 3 المراجعة النهائية لنصف العام
Math primar primary 3 المراجعة النهائية لنصف العام
 
histgram[1].ppt
histgram[1].ppthistgram[1].ppt
histgram[1].ppt
 
Sql lab experiments
Sql lab experimentsSql lab experiments
Sql lab experiments
 

More from Sai Sathvick Chirakala

More from Sai Sathvick Chirakala (10)

Characteristics of healthy personality
Characteristics of healthy personalityCharacteristics of healthy personality
Characteristics of healthy personality
 
Mysql and html
Mysql and html Mysql and html
Mysql and html
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
content of cold drinks available in the market-chemistry investigatory project
content of cold drinks available in the market-chemistry investigatory projectcontent of cold drinks available in the market-chemistry investigatory project
content of cold drinks available in the market-chemistry investigatory project
 
Physics project class 12 EMI
Physics project class 12 EMIPhysics project class 12 EMI
Physics project class 12 EMI
 
02 chapter 11 thermodynamics
02 chapter 11 thermodynamics02 chapter 11 thermodynamics
02 chapter 11 thermodynamics
 
Chapter 11 equilibrium lecture notes
Chapter 11 equilibrium lecture notesChapter 11 equilibrium lecture notes
Chapter 11 equilibrium lecture notes
 
Class ion exchange 22 oct 08
Class ion exchange 22 oct 08Class ion exchange 22 oct 08
Class ion exchange 22 oct 08
 
The frog and the nightingle
The frog and the nightingleThe frog and the nightingle
The frog and the nightingle
 
Congruence of triangle
Congruence of triangleCongruence of triangle
Congruence of triangle
 

Recently uploaded

Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
ARTERIAL BLOOD GAS ANALYSIS........pptx
ARTERIAL BLOOD  GAS ANALYSIS........pptxARTERIAL BLOOD  GAS ANALYSIS........pptx
ARTERIAL BLOOD GAS ANALYSIS........pptxAneriPatwari
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxAvaniJani1
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 

Recently uploaded (20)

Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
ARTERIAL BLOOD GAS ANALYSIS........pptx
ARTERIAL BLOOD  GAS ANALYSIS........pptxARTERIAL BLOOD  GAS ANALYSIS........pptx
ARTERIAL BLOOD GAS ANALYSIS........pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptx
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 

SQL QUERIES FOR EMPLOYEE TABLE

  • 1. 1) Answer the following queries based on the given table:EMP NO. ENAME JOB SALARY DEPT.NO. 7680 SCOTT MANAGER 20,000 10 7688 JACK CLERK 5,000 20 7454 MACK ANALYST 2,000 10 7210 BEN MANAGER 20,000 30 7621 MARTIN SALESMAN 15,000 40 a) Write a query to display the list of employee with salary. Ans:- select ename ,sal fromemp; b) Write a query to display all the records of employee table. Ans:- select empno,ename,job,sal , dept no fromemp; c) Write a query to display the name of employee along with designation & salary. Ans:- select ename,job,sal fromemp; d) Write a query to display the list of employees who get salary more than 10,000. Ans:- select ename fromemp wheresal> 10,000; e) Write a query to display all records of dept no. 10. Ans:- select* from emp where dept no=10;
  • 2. 2) Table 1.2 shows the records of a shop named customers. Give the query to the questions asked based on the table. CUST NO. NAME AMOUNT(RS/-) PRODUCT 101 ALKA 20 MAGGI 509 SURESH 467 KISSAN JAM 01 MAHIMA 945 PULSES 240 DECK 1,000 RICE 109 HEENA 45 MACRONI a) Write a query to display all the records of purchase of pulses product. Ans:- select* from customer where product=`pulses’; b) Write a query to display the total sales(in terms of rupee). Total sales=amount * 20 Ans:- select amount * 20 “total sales” from customer; c) Write a query to display the name of customers with product whose name starts from H and ends with A. Ans:- select name,product from customer where namelike`H%A’ ; d) Write a query to display all the records of cust no.109 Ans:- select* from customer wherecust no=109 ;
  • 3. 3) Write sql commands for the following on the basis of the table student. STUDENT NO. CLASS NAME GAME GRADE 1 SUPW 10 7 SAMEER CRICKET B PHOTOGRAPHY A 11 8 SUJIT TENNIS A GARDENING 12 7 KAMAL SWIMMING B PHOTOGRAPHY B 13 7 VEENA TENNIS C COOKING A 14 9 ARCHANA BASKET BALL A LITERATURE A 15 10 ARPIT CRICKET A GARDENING C GRADE 2 C a) Display the name of the students who are getting a grade `c’ in either game or supw. Ans:- select name from student whereGrade 1 =`C’ or Grade 2 = `C’ ; b) Display the different games offered in the school. Ans:- select distinct (Game) from student; c) Display the SUPW taken up by the students whose name starts with `A’. Ans:- select SUPW from student where name LIKE `A%’;
  • 4. 4) Write sql commands for the following on the basis of the given table CLUB. COACH- ID COACH NAME AGE SPOERTS DATE OF APP PAY SEX 1 KUKREJA 34 KARATE 27/3/1996 1000 M 2 RAVINA 34 KARATE 20/01/1998 1200 F 3 KARAN 34 SQUASH 19/02/1998 2000 M 4 TARUN 33 BASKETBALL 01/01/1998 1500 M 5 ZUBIN 36 SWIMMING 12/01/1998 750 M 6 KETAKI 36 SWIMMING 24/02/1998 800 F 7 ANKITA 39 SQUASH 20/02/1998 2200 F 8 ZAREEN 37 KARATE 22.02/1998 1100 F 9 KUSH 41 SWIMMING 13/01/1998 900 M 10 SHAILYA 37 BASKETBALL 19/02/1998 1700 M a) To show all the information about the swimming coaches in the club. Ans:- select* from club where sports=`SWIMMING’; b) To list the names of all coaches with their date of appointment (date of app) in descending order. Ans:- select COACH NAME, DATE OF APP from club order by DATE OF APP desc; c) To display a report, showing coachname, pay, age & bonus (15% of pay) for all the coaches. Ans:- select COACHNAME,PAY,AGE,P*15 “BONUS” from club;
  • 5. 5) Write sql commands for the following on the basis of the given table STUDENT 1. NO NAME STIPEND STREAM AVG. MARKS GRADE CLASS 1 KARAN 400.00 MEDICAL 78.5 B 12B 2 DIVAKAR 450.00 COMMERCE 89.2 A 11C 3 DIVYA 300.00 COMMERCE 68.6 C 12C 4 ARUN 350.00 HUMANITIES 73.1 B 12C 5 SABINA 500.00 NON-MEDICAL 90.6 A 11A 6 JOHN 400.00 MEDICAL 75.4 B 12B 7 ROBERT 250.00 HUMANITIES 64.4 C 11A 8 RUBINA 450.00 NON-MEDICAL 88.5 A 12A 9 VIKAS 500.00 NON-MEDICAL 92.0 A 12A 10 MOHAN 300.00 COMMERCE 67.5 C 12C a) select all the numerical stream students from STUDENT 1. Ans:- select name,stream from STUDENT 1 where stream= `non-medical’; b) list all name os those students who are in class 12 sorted by stepend. Ans:- select name from STUDENT 1 where class LIKE `12-’ Order By stipend; c) list all students stored by average marks in descending order. Ans:- select name from STUDENT 1 Order by avg. marks DESC; d) display a report, listing name, stipend,stream& amount of stipend received in a year assuming that the stipend is paid every month. Ans:- select name,stipend * 12,stream from STUDENT1 ;
  • 6. 6) Write sql commands for the following on the basis of given table LIBRARY. NO. TITLE AUTHOR TYPE PUB QUANTITY PRICE 1 DATA STRUCTURE LIPSCHUTZ DS MC GRAW 4 217 2 COMPUTER STUDIES FRENCH FND GALGOTIA 2 75 3 ADVANCE PASCAL SCHILDT PROG MC GRAW 4 350 4 DBASE DUMMIES PALMER DBMS PUSTALE M 5 130 5 MASTERING C++ GWEWICH PROG BPB 3 295 6 GUIDE NETWORK FREED NET Z PRESS 3 200 7 MASTERING FOXPRO SEIGAL BDMS BPB 2 135 8 DOS GUIDE MORTON OS PHI 3 175 9 BASIC FOR BEGINNERS MORTON PROG BPB 3 40 10 MASTERING WINDOWS COWARD OS BPB 1 225 a) Select all the PROG type published by BPB from library. Ans:- select* from library where type= `PROG’AND PUB= `BPB’ ; b) Display a list of all books with price more than 130&sDrted by qty. Ans:- select* from library where price>130 Order by qty; c) Display all the books sorted by price in ascending order. Ans:- select* from library Order by price ASCE;
  • 7. 7) Write NO. TITLE sql commands for the following on the basis of the given table MOV. TYPE RATING STARS QTY. PRICE 1 GONE WITH THE WIND DRAMA G GABLE 4 39.95 2 FRIDAY THE 13th HORROW R JASON 2 69.95 3 TOP GUN DRAMA PG CRUISE 7 49.95 4 SPLASH COMEDY PG13 HANKS 3 29.95 5 INDEPENDENT DAY DRAMA R TURNER 3 19.95 6 RISKY BUSINESS COMEDY R CRUISE 2 44.95 7 COCOON SCIFI PG AMECHE 2 31.95 8 CROCODILE DUNDEE COMEDY PG13 HARRIS 2 69.95 9 101 DALMATIANS COMEDY G PATTINSON 3 59.95 10 TOOTSIE COMEDY PG HOFFMAN 1 29.95 a) Display a list of all movies with price over 20 & sorted by price Ans :- select Title , price from MOV where price >20 Order by price; b) Display all the movies sorted by QTYin decreasing order Ans :- select *from MOV Order by qty DESC; c) Display a report listing a movie number , current value & replacement value for each movie in the given table. Calculate the replacement value for all the movies as aty*price*1.15. Ans:- select no., price,qty.*price*1.15 from MOV Group by no;
  • 8. 8) Write sql commands for the following on the basis of the given table GRADUATE. S.NO. NAME STIPEND SUBJECT AVERAGE RANK 1 KARAN 400 PHYSICS 68 1 2 DIVAKAR 450 COMPUTER SCIENCE 68 1 3 DIVYA 300 CHEMISTRY 62 2 4 ARUN 350 PHYSICS 63 1 5 SABINA 500 MATHEMATICS 70 1 6 JPHN 400 CHEMISTRY 55 2 7 ROBERT 250 PHYSICS 64 1 8 RUBINA 450 MATHEMATICS 68 1 9 VIKAS 500 COMPUTER SCIENCE 62 1 10 MOHAN 300 MATHEMATICS 57 2 a) List the names of those students who have obtained rank 1 by NAME. Ans:- select NAME from graduate where rank=`1’ Order by NAME; b) Display a report listing NAME,STIPEND,SUBJECT& amount of stipend received in a year assuming that the STIPEND is paid every month. Ans:- select NAME, STIPEND,SUBJECT,STIPEND * 12 from GRADUATE;
  • 9. 9) Write sql commands for the following on the basis of the given table Teacher. NO. NAME AGE DEPARTMENT DATE OF JOIN SALARY SEX 1 JUGAL 34 COMPUTER 10/01/97 12000 M 2 SHARMILA 31 HISTORY 24/03/98 20000 F 3 SANDEP 32 MATHS 12/12/96 30000 M 4 SANGEETA 35 HISTORY 01/07/99 40000 F 5 RAKESH 42 MATHS 05/09/97 25000 M 6 SHYAM 50 HISTORY 27/06/98 30000 M 7 SHIV OM 44 COMPUTER 25/02/97 21000 M 8 SHALAKHA 33 MATHS 31/07/97 20000 F a) To show all information about the teacher of history department. Ans:- select* from teacher where Department=`HISTORY’; b) To list the names of female teachers who are in mathsdepartment. Ans:- select name from teacher where department=`MATHS’ AND sex=`F’; c) To list the names of all teachers with their date of joining in ascending order. Ans:- select Name, Date of join from teacher Order by Date of join ASC;
  • 10. 10) Write a query to create table student having following specifications:Column name type size constraint Sname char 40 Cls int >6 Marks number 2,2 unique default Ans:-Create table student ( sid number primary key, sname char(40) unique, clsint check(cls.6), marks number(2,2) default=12); 11) Write a query to create table customer having following specifications:Column name type size constraint Cno. Number 3 Name varchar 10 Amount Float - >5000 comn Number - Default=1001 A ns:- Create table customer ( cno number(3) primary key, name varchar(10), amount float check(amount>5000), comn number default=1001); Primary
  • 11. 12) Write a query to create table ITEM Column name type Item no. Number Item name Varchar 40 Amount Number 4,2 Qty. number Ans:- create table Item ( Item no number primary, Inamevarchar(40), Amount number(4,2), Qty number check (qty>100) ); size constraint primary >100
  • 12. 13) Write queries based on the following table PET. NAME OWNER SPECIES SEX BIRTH DEATH FLUFFY HAROLD CAT F 4/2/1993 NULL CLAWS GWEN CAT M 17/3/1994 NULL BUFFY HAROLD DOG F 13/5/1989 NULL FANG BENNY DOG M 27/8/1990 NULL BROWSER DIANE DOG M 31/8/1979 29/7/1995 EHIRPY GWEN BIRD F 11/9/1998 NULL WHISTLER GWEN BIRD NULL 9/12/1997 NULL SLIM BENNY SNAKE M 29/4/1996 NULL PUFFBALL DIANE HAMSTER F 30/3/199 NULL a) Display all the details from PET table for species cat/dog having gender (sex )as male(`M’). Ans:-select* from PET where (species=`cat’||specie=`dog’) && sex=`m’; b) Display all details of pet of species bird,snake or hamster from table PET Ans:- select* from PET where species in (`bird’,`snake’,`hamster’); c) Display the names of pets who are no more. Ans:- select name from PET where death IS NOT NULL;
  • 13. 14) Consider the table EXAM given.Write commands in mysql. NO NAME STIPEND SUBJECT AVG. DIVISION 1 KARAN 400 ENGLISH 68 FIRST 2 AMAN 680 MATHS 72 FIRST 3 JAVED 500 ACOUNTS 67 FIRST 4 BISHAKH 200 INFORMATICS 55 SECOND 5 SUGANDHA 400 HISTORY 35 THIRD 6 SUPARNA 550 GEOGRAPHY 45 THIRD a) To list the names of those students, who have obtained division as FIRST in the ascending order of NAME. b) Ans:- select name,division from EXAM where division=`FIRST’ Order by NAME ASC; c) To display a report listing name, subject, annual stipend received assuming that the stipend column has monthly stipend. Ans: select name, stpend,subject * 12 from EXAM; d) To count the number of students who have either accounts or informatics as subject. Ans:- select name from EXAM where subject=`Accounts’ or subject=`Informatics’;
  • 14. 15) Write sql commands based on the given table EMPL. EMP NO ENAME JOB MGR. HIREDATE SAL COMM. 8369 SMITH CLERK 8902 18/12/1990 800 NULL 8499 ANYA SALESMAN 8698 4/2/1990 1600 300 8521 SETH MANAGER 8698 18/7/1991 2000 500 8566 MAHADEVAN SALESMAN 8839 30/4/1990 400 NULL 8698 MOMIN CLERK NULL 28/6/1992 7800 1400 8888 BEENA ANALYST 8854 4/8/1990 2000 NULL 8900 AMIR CLERK 6478 4/4/1991 1100 NULL 8844 KULDEEP PRESIDENT 8522 8/9/1999 5000 0.00 a) Cunt number of records in table employee. Ans:-select count(*) “Total” b) c) d) e) from EMPL; Count number of jobs in table EMPL. Ans:- select count(job) “job count “ from EMPL; How many distinct jobs are listed in the table EMPL. Ans:- select count(distinct job) “distict jobs” from EMPL; Display max. salary from the table EMPL. Ans:- select max(sal) “maximum salary” from EMPL; Display the joining date of senior most employee. Ans:- select MIN (hiredate) “minimum hiredate” From EMPL;