Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 186

[Title]

Workbook

Admin
Employee ID

[Company E-mail]

February 6, 2022

For the Academy Training Program with TLS-ET


From: February 6, 2022

To: February 6, 2022

Version: 3
Table of Contents
About me...............................................................................................................................................3
Exercise - 1.............................................................................................................................................4
Exercise - 2...........................................................................................................................................56
Exercise - 3...........................................................................................................................................74
Exercise - 4...........................................................................................................................................93
Exercise - 5.........................................................................................................................................142
Exercise - 6.........................................................................................................................................157
About me

Declaration
I declare that this workbook and reports are my own work, based on my personal
study and/or research and that I have not copied in part or whole or otherwise
plagiarized the work of other trainees and/or persons.

Name: Admin
Date: [Publish Date]
Exercise - 1

Problem Statement:
1. Find out the selling cost avg for packages developed in pascal

Solution:
select AVG(Scost) AS SELLINGCOST from Software where Dev_In='PASCAL'

Input:

Output:
SELLINGCOST

3066.33333333333

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
2. Display name, ages of all programmers

Solution:
select pname,year(getdate()) -year(dob) as Age from Programmer

Input:

Output:
ANAND 55

ALTAF 57

JULIANA 53

KAMALA 53

MARY 51

NELSON 36

PATRICK 56

QADIR 56

RAMESH 54

REBECCA 54

REMITHA 51

REVATHI 52

VIJAYA 56

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
3. Display the names of those who have done the Dap course

Solution:
SELECT Pname FROM Software WHERE Dev_In='DBASE';

Input:

Output:
Pname

KAMALA

RAMESH

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
4. Display the name and DOB of all programmers born in January

Solution:
SELECT PNAME,Dob FROM Programmer WHERE MONTH(Dob)=1

Input:

Output:
PNAME Dob

JULIANA 1968-01-31

REBECCA 1967-01-01

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
5. What is the highest no. of copies sold by a package

Solution:
SELECT * FROM Software WHERE SOLD =(SELECT MAX(Sold) FROM SOFTWARE);

Input:

Output:
Pname Title Dev_In Scost Dcost Sold

QADIR READ ME C++ 300 120 84

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
6. Display lowest course fee

Solution:
SELECT MIN(COST) FROM STUDIES

Input:

Output:
(No column name)

4500

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
7. How many programmers done a PGDCA course

Solution:
select p.Pname from Programmer p,Studies s
where p.Pname=s.Pname and s.Course='PGDCA'

Input:

Output:
Pname Dob Doj Sex Prof1 Prof2 Salary

ANAND 1966-04-21 1992-04-21 M PASCAL BASIC 3200

MARY 1970-06-24 1991-02-01 F C++ ORACLE 4500

PATRICK 1965-11-10 1990-04-21 M PASCAL CLIPPER 2800

RAMESH 1967-05-03 1991-02-28 M PASCAL DBASE 3200

REVATHI 1969-12-02 1992-01-02 F PASCAL BASIC 3700

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
8.How much revenue has been earned through sales of packages developed in C

Solution:
SELECT sum(Scost) as Total from Software where Dev_In='C';

Input:

Output:
Total

3525

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
9. Display the details of the software developed by ramesh

Solution:
SELECT DEV_IN FROM Software WHERE Pname='RAMESH';

Input:

Output:
DEV_IN

DBASE

PASCAL

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
10. How many programmers studied at sabhari

Solution:
SELECT P.* from Programmer p,Studies s
where P.Pname=S.Pname AND s.Splace='SABHARI';

Input:

Output:
Pname Dob Doj Sex Prof1 Prof2 Salary

ANAND 1966-04-21 1992-04-21 M PASCAL BASIC 3200

MARY 1970-06-24 1991-02-01 F C++ ORACLE 4500

PATRICK 1965-11-10 1990-04-21 M PASCAL CLIPPER 2800

RAMESH 1967-05-03 1991-02-28 M PASCAL DBASE 3200

REVATHI 1969-12-02 1992-01-02 F PASCAL BASIC 3700

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
11.Display details of packages whose sales crossed the 2000 mark

Solution:
SELECT * FROM Software WHERE Scost>2000

Input:

Output:
Pname Title Dev_In Scost Dcost Sold

ANAND VIDEO TITLING PACK PASCAL 7500 16000 9

JULIANA INVENTORY CONTROL COBOL 3000 3500 0

KAMALA PAYROLL PACKAGE DBASE 9000 20000 7

MARY FINANCIAL ACC.S/W ORACLE 18000 85000 4

PATRICK CODE GENERATION COBOL 4500 20000 23

RAMESH HOTEL MANAGEMENT DBASE 12000 3500 4

REMITHA TSR HELP PACKAGE ASSEMBLY 2500 6000 6

REVATHI QUIZ MASTER BASIC 3200 2100 15

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement
13. What is the costliest software development in the basic

Solution:
select * from Software where Dev_In='Basic' and Dcost=(select max(Dcost) from
Software where Dev_In='Basic')

Input:

Output:
Pname Title Dev_In Scost Dcost Sold

ANAND PARACHUTES BASIC 399 6000 43

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
14. How many packages developed in dbase

Solution:
select count(title) as TotalPackages from Software where Dev_In='DBASE'

Input:

Output:
TotalPackages

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
15. How many programmers studied in pragathi

Solution:
select count(Pname) as Total from Studies where Splace='PRAGATHI'

Input:

Output:
Total

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
16. How many programmers payed 5000 to 10000 for their course

Solution:
SELECT * FROM Studies WHERE Cost BETWEEN 5000 AND 10000

Input:

Output:
Pname Splace Course Cost

ALTAF COIT DCA 7200

KAMALA PRAGATHI DCP 5000

NELSON PRAGATHI DAP 6200

PATRICK SABHARI DCA 5200

REMITHA BDPS DCS 6000

REVATHI SABHARI DAP 5000

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
17. What is AVG course fee

Solution:
SELECT AVG(Cost) FROM Studies

Input:

Output:
AverageFee

11015

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
18. Display the details of the programmers knowing C

Solution:
select * from Programmer where Prof1='C' or Prof2='C'

Input:

Output:
AverageFee

11015

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
19. How many programmers know either cobol or pascal

Solution:
select * from Programmer where Prof1 IN ('COBOL','PASCAL') OR Prof2
IN('COBOL','PASCAL')

Input:

Output:
Pname Dob Doj Sex Prof1 Prof2 Salary

ANAND 1966-04-21 1992-04-21 M PASCAL BASIC 3200

ALTAF 1964-07-02 1990-11-13 M CLIPPER COBOL 2800

JULIANA 1968-01-31 1990-04-01 F COBOL DBASE 3000

NELSON 1985-09-11 1989-10-11 M COBOL DBASE 2500

PATRICK 1965-11-10 1990-04-21 M PASCAL CLIPPER 2800

RAMESH 1967-05-03 1991-02-28 M PASCAL DBASE 3200

REBECCA 1967-01-01 1990-12-01 F BASIC COBOL 2500

REVATHI 1969-12-02 1992-01-02 F PASCAL BASIC 3700

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
20. How Many programmers don’t know pascal and C

Solution:
select * from Programmer where Prof1 NOT IN ('PASCAL','C') AND Prof2 NOT
IN('PASCAL','C')

Input:

Output:
Pname Dob Doj Sex Prof1 Prof2 Salary

ALTAF 1964-07-02 1990-11-13 M CLIPPER COBOL 2800

JULIANA 1968-01-31 1990-04-01 F COBOL DBASE 3000

MARY 1970-06-24 1991-02-01 F C++ ORACLE 4500

NELSON 1985-09-11 1989-10-11 M COBOL DBASE 2500

REBECCA 1967-01-01 1990-12-01 F BASIC COBOL 2500

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
21. How old is the oldest male programmer?

Solution:
select max(YEAR(Doj)-Year(Dob)) Older from Programmer WHERE SEX = 'M';

Input:

Output:
Older

26

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
22. What is the avg age of female programmer

Solution:
select Avg(YEAR(Doj)-Year(Dob)) Older from Programmer where Sex='F'

Input:

Output:
Older

23

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
23.Calculate the experience in years for each programmer and display with their
names in
--descending order

Solution:
select Pname,(YEAR(Doj)-Year(Dob)) Year from Programmer order by Pname desc

Input:

Output:
Pname Year

VIJAYA 27

REVATHI 23

REMITHA 23

REBECCA 23

RAMESH 24

QADIR 26

PATRICK 25

NELSON 4

MARY 21

KAMALA 24

JULIANA 22

ANAND 26

ALTAF 26

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
24. Who are the programmers who celebrate their birthday during the current month?

Solution:
select Pname from Programmer where Month(Dob)=datepart(mm,getdate())

Input:

Output:
Pname

REVATHI

VIJAYA

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
25. How many female programmers are there?

Solution:
select count(Pname) as TotalFemales from Programmer where Sex='F'

Input:

Output:
TotalFemales

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
26. What are the languages studied by the male programmers?

Solution:
select CONCAT(Prof1,',',Prof2) as Languages from Programmer where Sex='M'

Input:

Output:
Languages

PASCAL,BASIC

CLIPPER,COBOL

COBOL,DBASE

PASCAL,CLIPPER

ASSEMBLY,C

PASCAL,DBASE

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
27. What is the AVG salary

Solution:
select Avg(salary) as AverageSalary from Programmer;

Input:

Output:
AverageSalary

3169.23076923077

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
28. How many people draw salary 2000-4000

Solution:
select count(pname) as People from Programmer where Salary between 2000 and 4000;

Input:

Output:
People

12

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
29. Display the details of those who don’t know clipper, cobol or pascal

Solution:
select * from Programmer where Prof1 Not in ('CLIPPER','COBOL','PASCAL') or Prof2
Not in('CLIPPER','COBOL','PASCAL') ;

Input:

Output:
Pname Dob Doj Sex Prof1 Prof2 Salary

ANAND 1966-04-21 1992-04-21 M PASCAL BASIC 3200

JULIANA 1968-01-31 1990-04-01 F COBOL DBASE 3000

KAMALA 1968-10-30 1992-01-02 F C DBASE 2900

MARY 1970-06-24 1991-02-01 F C++ ORACLE 4500

NELSON 1985-09-11 1989-10-11 M COBOL DBASE 2500

QADIR 1965-08-31 1991-04-21 M ASSEMBLY C 3000

RAMESH 1967-05-03 1991-02-28 M PASCAL DBASE 3200

REBECCA 1967-01-01 1990-12-01 F BASIC COBOL 2500

REMITHA 1970-04-19 1993-04-20 F C ASSEMBLY 3600

REVATHI 1969-12-02 1992-01-02 F PASCAL BASIC 3700

VIJAYA 1965-12-14 1992-05-02 F FOXPRO C 3500

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
30.Display the cost of package developed by each programmer

Solution:
select P.Pname, S.Cost from Programmer P,Studies S
where p.Pname=S.Pname;

Input:

Output:
Pname Cost

ANAND 4500

ALTAF 7200

JULIANA 22000

KAMALA 5000

MARY 4600
NELSON 6200

PATRICK 5200

QADIR 14000

RAMESH 4500

REBECCA 11000

REMITHA 6000

REVATHI 5000

VIJAYA 48000

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
31. Display the sales values of the packages developed by each programmer

Solution:
select P.Pname, S.Scost As Sales from Software S,Programmer P
where S.Pname=P.Pname
Input:

Output:
Pname Sales

ANAND 399

ANAND 7500

JULIANA 3000

KAMALA 9000

MARY 18000

PATRICK 4500

QADIR 300

QADIR 750

QADIR 1900

RAMESH 12000

RAMESH 599

REMITHA 725

REMITHA 2500

REVATHI 1100

REVATHI 3200

VIJAYA 900

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
32. Display the no. of packages sold by each programmer

Solution:
SELECT Pname AS PRNAME,COUNT(TITLE)AS NOOFPACK
FROM SOFTWARE
GROUP BY Pname

Input:

Output:
PRNAME NOOFPACK

ANAND 2

JULIANA 1

KAMALA 1

MARY 1

PATRICK 1

QADIR 3

RAMESH 2

REMITHA 2

REVATHI 2

VIJAYA 1

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
33. Display the sales cost of the packages developed by each programmer language
wise

Solution:
SELECT SUM(SCOST) AS SELLCOST
FROM SOFTWARE
GROUP BY DEV_IN

Input:

Output:
SELLCOST

3250

3599

3525

300

7500
21000

18000

9199

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
34. Display each language name with AVG development cost, AVG selling cost and AVG
price per --copy

Solution:
SELECT DEV_IN AS LANGUAGE,AVG(DCOST) AS AVGDEVCOST,AVG(SCOST) AS
AVGSELLCOST,AVG(SCOST) AS PRICEPERCPY
FROM SOFTWARE
GROUP BY DEV_IN

Input:

Output:
LANGUAGE AVGDEVCOST AVGSELLCOST PRICEPERCPY

ASSEMBLY 5500 1625 1625

BASIC 4050 1799.5 1799.5

C 3033.33333333333 1175 1175

C++ 1200 300 300

COBOL 11750 3750 3750

DBASE 11750 10500 10500

ORACLE 85000 18000 18000

PASCAL 31833.3333333333 3066.33333333333 3066.33333333333

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
35. Display each institute name with no. of course, avg. cost per course

Solution:
SELECT SPLACE AS INSTITUTE,COUNT(COURSE) AS NOOFCOURS,AVG(COST) AS AVGCOSTPERCOUR
FROM STUDIES
GROUP BY SPLACE

Input:

Output:
INSTITUTE NOOFCOURS AVGCOSTPERCOUR

APPLE 1 14000

BDPS 2 27000

BITS 1 22000

BPILLANI 1 11000

COIT 1 7200

PRAGATHI 2 5600

SABHARI 5 4760

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
37. Display each institute name for with no. of students

Solution:
SELECT SPLACE AS INSTITUTE,COUNT(Pname) AS NOOFSTUD
FROM STUDIES
GROUP BY SPLACE

Input:

Output:
INSTITUTE NOOFSTUD

APPLE 1

BDPS 2

BITS 1

BPILLANI 1

COIT 1

PRAGATHI 2

SABHARI 5

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
38.Display names of male and female programmers, gender also

Solution:
SELECT Pname AS PRNAME,SEX AS SEX
FROM PROGRAMMER
ORDER BY SEX

Input:

Output:
PRNAME SEX

JULIANA F

KAMALA F

MARY F

REBECCA F

REMITHA F

REVATHI F

VIJAYA F

NELSON M

PATRICK M
QADIR M

RAMESH M

ANAND M

ALTAF M

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
39. Display the name of programmers and their packages

Solution:
SELECT Pname AS PRNAME,TITLE AS PACKAGE
FROM SOFTWARE
ORDER BY Pname

Input:
Output:
PRNAME PACKAGE

ANAND PARACHUTES

ANAND VIDEO TITLING PACK

JULIANA INVENTORY CONTROL

KAMALA PAYROLL PACKAGE

MARY FINANCIAL ACC.S/W

PATRICK CODE GENERATION

QADIR READ ME

QADIR BOMBS AWAY

QADIR VACCINES

RAMESH HOTEL MANAGEMENT

RAMESH DEAD LEE

REMITHA PC UTILITIES

REMITHA TSR HELP PACKAGE

REVATHI HOSPITAL MANAGEMENT

REVATHI QUIZ MASTER

VIJAYA ISR EDITION

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
40. Display the no. of packages in each language expect C and C++

Solution:
SELECT COUNT(TITLE) AS NOOFPACK,DEV_IN AS LANGUAGE
FROM SOFTWARE
where DEV_IN not in('C','C++')
GROUP BY DEV_IN

Input:

Output:
NOOFPACK LANGUAGE

2 ASSEMBLY

2 BASIC

2 COBOL

2 DBASE

1 ORACLE

3 PASCAL

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
41. Display the no. of packages in each language for which development cost is less
than 1000

Solution:
SELECT COUNT(TITLE) AS NOOFPACK,DEV_IN AS LANGUAGE
FROM SOFTWARE
WHERE DCOST<1000 GROUP BY DEV_IN

Input:

Output:
NOOFPACK LANGUAGE

1 C

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
42. Display the total SCOST, DCOST AND Amount to be recovered for each programmer
for those
--whose cost has not yet been recovered

Solution:
SELECT SUM(SCOST), SUM(DCOST), SUM(DCOST-(SOLD*SCOST)) FROM SOFTWARE GROUP BY pNAME
HAVING SUM(DCOST)>SUM(SOLD*SCOST)

Input:

Output:
(No column name) (No column name) (No column name)

3000 3500 3500

18000 85000 13000

4300 77100 26900

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
43. Display AVG difference between SCOST, DCOST for each package

Solution:
SELECT DEV_IN AS LANGUAGE,AVG(DCOST - SCOST) AS DIFF FROM SOFTWARE GROUP BY DEV_IN

Input:

Output:
LANGUAGE DIFF

ASSEMBLY 3875

BASIC 2250.5

C 1858.33333333333

C++ 900

COBOL 8000

DBASE 1250

ORACLE 67000

PASCAL 28767

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
44. Display highest, lowest and average salaries for those earning more than 2000

Solution:
SELECT MAX(SALARY), MIN(SALARY), AVG(SALARY)
FROM PROGRAMMER
WHERE SALARY > 2000

Input:

Output:
(No column name) (No column name) (No column name)

4500 2500 3169.23076923077

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
45. Who is the highest paid C programmer?

Solution:
SELECT * FROM PROGRAMMER
WHERE SALARY=(SELECT MAX(SALARY)
FROM PROGRAMMER WHERE PROF1 = 'C' OR PROF2 = 'C')

Input:

Output:
Pname Dob Doj Sex Prof1 Prof2 Salary

REMITHA 1970-04-19 1993-04-20 F C ASSEMBLY 3600

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
46. Who is the highest paid female programmer?

Solution:
SELECT * FROM PROGRAMMER
WHERE SALARY=(SELECT MAX(SALARY)
FROM PROGRAMMER
where SEX = 'F')

Input:

Output:
Pname Dob Doj Sex Prof1 Prof2 Salary

MARY 1970-06-24 1991-02-01 F C++ ORACLE 4500

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
47. Display the name of the highest paid programmers for each language

Solution:
SELECT DISTINCT Pname, SALARY, PROF1
FROM PROGRAMMER WHERE (Salary) IN (SELECT MAX(SALARY)
FROM PROGRAMMER) and (PROF1) in (select max(PROF1) from Programmer
GROUP BY PROF1)

Input:

Output:
Pname SALARY PROF1

MARY 4500 C++

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
48. Who is the least experience programmer?

Solution:
SELECT (datepart(yy,GETDATE())-datepart(yy,Doj)) as EXP,pname
FROM PROGRAMMER where datepart(yy,GETDATE())-datepart(yy,Doj) in (select
min(datepart(yy,GETDATE())-datepart(yy,Doj))as EXP FROM PROGRAMMER)

Input:

Output:
EXP pname

28 REMITHA

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
49. Who is the most experience male programmer knowing pascal

Solution:
SELECT (datepart(yy,GETDATE())-datepart(yy,Doj)) as EXP,pname
FROM PROGRAMMER where Sex='M' and datepart(yy,GETDATE())-datepart(yy,Doj) in
(select max(datepart(yy,GETDATE())-datepart(yy,Doj))as EXP FROM PROGRAMMER)

Input:

Output:
EXP pname

32 NELSON

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
50. Which language is known by only one programmer?

Solution:
SELECT PROF1
FROM PROGRAMMER
GROUP BY PROF1
HAVING PROF1 NOT IN
(SELECT PROF2 FROM PROGRAMMER)
AND COUNT(PROF1)=1
UNION
SELECT PROF2
FROM PROGRAMMER
GROUP BY PROF2
HAVING PROF2 NOT IN
(SELECT PROF1 FROM PROGRAMMER)
AND COUNT(PROF2)=1;

Input:

Output:
EXP pname

32 NELSON

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Exercise - 2

Problem Statement:
1. Calculate the amount to be recovered for those packages whose development cost
has not yet
--been recovered?

Solution:
SELECT (DCOST-(SCOST*SOLD)),TITLE
FROM SOFTWARE where (Dev_In='COBOL' and Pname='JULIANA')

Input:

Output:
(No column name) TITLE

3500 INVENTORY CONTROL

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
2. List the packages, which have not been sold so far?

Solution:
select title from software where sold=0

Input:

Output:
title

INVENTORY CONTROL

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
3. Find out the cost of the software developed by Mary?

Solution:
select sum(sold*Scost) from Software where Pname='Mary'

Input:

Output:
(No column name)

72000

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
4. Display the institute names from the studies table without the duplicates

Solution:
select distinct(splace) from Studies

Input:

Output:
splace

APPLE

BDPS

BITS

BPILLANI

COIT

PRAGATHI

SABHARI

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
5. How many different courses are mentioned in the studies table?

Solution:
select distinct(course) from Studies

Input:

Output:
course

DAP

DCA

DCP

DCS

HDCP

MCA

PGDCA

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
6. Display the names of the programmers whose names contain 2 occurrences of the
letter ‘A’

Solution:
SELECT pNAME FROM PROGRAMMER WHERE pNAME LIKE '%A%A%'

Input:

Output:
pNAME

ANAND

ALTAF

JULIANA

KAMALA

VIJAYA

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
7. Display the names of the programmers whose names contains 5 characters

Solution:
SELECT pNAME FROM PROGRAMMER WHERE pNAME LIKE '_____' and LEN(pname)=5

Input:

Output:
pNAME

ANAND

ALTAF

QADIR

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
8. How many female programmers knowing COBOL have more than 2yrs experience

Solution:
select count(DATEPART(yy,Doj)-DATEPART(yy,Dob)) from Programmer where
DATEPART(yy,Doj)-DATEPART(yy,Dob)>5 and Sex='F' and Prof1 in('COBOL')
or prof2 in ('COBOL')

Input:

Output:
(No column name)

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
9. What is the length of the shortest name in the programmer table

Solution:
select min(len(pname)) from Programmer;

Input:

Output:
(No column name)

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
10. What is the average development cost of a package developed in COBOL

Solution:
select avg(Dcost) from Software where Dev_in='COBOL'

Input:

Output:
(No column name)

11750

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:

11. Display the name, sex, dob (dd/mm/yy format), DOJ (dd/mm/yy format) for all the
programmers

Solution:
select pname,sex,FORMAT (Dob, 'dd/MM/yy') as DOB,Format(Doj,'dd/MM/yy') from
Programmer

Input:

Output:
pname sex DOB (No column name)

ANAND M 21/04/66 21/04/92

ALTAF M 02/07/64 13/11/90

JULIANA F 31/01/68 01/04/90

KAMALA F 30/10/68 02/01/92

MARY F 24/06/70 01/02/91

NELSON M 11/09/85 11/10/89

PATRICK M 10/11/65 21/04/90

QADIR M 31/08/65 21/04/91

RAMESH M 03/05/67 28/02/91

REBECCA F 01/01/67 01/12/90

REMITHA F 19/04/70 20/04/93


REVATHI F 02/12/69 02/01/92

VIJAYA F 14/12/65 02/05/92

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts (Solved/Not
solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
12. What is the amount paid in salaries of the male programmers who don’t know
COBOL?

Solution:
SELECT SALARY AS SALOFPR
FROM PROGRAMMER
WHERE SEX='M'
AND (PROF1!='COBOL'
OR PROF2!='COBOL')

Input:
Output:
SALOFPR

3200

2800

2500

2800

3000

3200

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
13. Display the title, scost, dcost and difference between scost and dcost in
descending order of
--difference

Solution:
SELECT TITLE AS SOFTNAME,SCOST AS SOFTCOST,DCOST AS DEVCOST,DCOST - SCOST DIFF FROM
SOFTWARE
ORDER BY 4 DESC

Input:

Output:
SOFTNAME SOFTCOST DEVCOST DIFF

HOSPITAL MANAGEMENT 1100 75000 73900

FINANCIAL ACC.S/W 18000 85000 67000

CODE GENERATION 4500 20000 15500

PAYROLL PACKAGE 9000 20000 11000

VIDEO TITLING PACK 7500 16000 8500

PARACHUTES 399 6000 5601

PC UTILITIES 725 5000 4275

BOMBS AWAY 750 5000 4250

DEAD LEE 599 4500 3901

TSR HELP PACKAGE 2500 6000 3500

VACCINES 1900 3400 1500

READ ME 300 1200 900

INVENTORY CONTROL 3000 3500 500

ISR EDITION 900 700 -200

QUIZ MASTER 3200 2100 -1100

HOTEL MANAGEMENT 12000 3500 -8500

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
14. Display the names of the packages whose names contain more than 1 word

Solution:
SELECT TITLE AS PACKAGES
FROM SOFTWARE
WHERE TITLE LIKE '%%'

Input:

Output:
PACKAGES

PARACHUTES

VIDEO TITLING PACK

INVENTORY CONTROL

PAYROLL PACKAGE

FINANCIAL ACC.S/W

CODE GENERATION

READ ME

BOMBS AWAY

VACCINES

HOTEL MANAGEMENT

DEAD LEE

PC UTILITIES

TSR HELP PACKAGE

HOSPITAL MANAGEMENT

QUIZ MASTER

ISR EDITION

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
15. Display the name, dob, doj of those months of birth and month of joining are
same

Solution:
SELECT pNAME AS PRNAME
FROM PROGRAMMER
WHERE datepart(mm,dob)=datepart(mm,doj)

Input:

Output:
PRNAME

ANAND

REMITHA

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Exercise - 3

Problem Statement:
1. Display the cost of the package developed by each programmer

Solution:
SELECT Pname AS PRNAME,SUM(DCOST) AS TOTCOST
FROM SOFTWARE
GROUP BY Pname

Input:

Output:
PRNAME TOTCOST

ANAND 22000

JULIANA 3500

KAMALA 20000

MARY 85000

PATRICK 20000

QADIR 9600

RAMESH 8000

REMITHA 11000

REVATHI 77100

VIJAYA 700

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
2. Display the sales values of the packages developed by each programmer

Solution:
SELECT Pname AS PRNAME, SUM(SCOST*SOLD) AS SALESVAL
FROM SOFTWARE
GROUP BY pNAME

Input:

Output:
PRNAME SALESVAL

ANAND 84657

JULIANA 0

KAMALA 63000

MARY 72000

PATRICK 103500

QADIR 73350

RAMESH 91727

REMITHA 51975

REVATHI 50200

VIJAYA 5400
Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
3. Display the number of packages sold by each programmer

Solution:
SELECT Pname AS PRNAME,COUNT(TITLE) AS TOTPACK
FROM SOFTWARE
GROUP BY pNAME

Input:

Output:
PRNAME TOTPACK

ANAND 2

JULIANA 1

KAMALA 1
MARY 1

PATRICK 1

QADIR 3

RAMESH 2

REMITHA 2

REVATHI 2

VIJAYA 1

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
4. Display the sales cost of the packages developed by each programmer

Solution:
SELECT SUM(SCOST) AS SELLCOST
FROM SOFTWARE
GROUP BY DEV_IN

Input:

Output:
SELLCOST

3250

3599

3525

300

7500

21000

18000

9199

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
5. Display each language name with average development cost, average selling cost
and average
--price per copy

Solution:
SELECT DEV_IN AS LANGUAGE,AVG(DCOST) AS AVGDEVCOST,AVG(SCOST) AS
AVGSELLCOST,AVG(SCOST) AS PRICEPERCPY
FROM SOFTWARE
GROUP BY DEV_IN

Input:

Output:
LANGUAGE AVGDEVCOST AVGSELLCOST PRICEPERCPY

ASSEMBLY 5500 1625 1625

BASIC 4050 1799.5 1799.5

C 3033.33333333333 1175 1175

C++ 1200 300 300

COBOL 11750 3750 3750

DBASE 11750 10500 10500

ORACLE 85000 18000 18000

PASCAL 31833.3333333333 3066.33333333333 3066.33333333333

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
6. Display each programmer’s name, costliest package and cheapest packages developed
by him /
--her.

Solution:
SELECT Pname PRNAME,MIN(DCOST) CHEAPEST,MAX(DCOST) COSTLIEST
FROM SOFTWARE
GROUP BY pNAME

Input:

Output:
PRNAME CHEAPEST COSTLIEST

ANAND 6000 16000

JULIANA 3500 3500

KAMALA 20000 20000

MARY 85000 85000

PATRICK 20000 20000

QADIR 1200 5000


RAMESH 3500 4500

REMITHA 5000 6000

REVATHI 2100 75000

VIJAYA 700 700

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
7. Display each institute name with number of courses, average cost per course

Solution:
SELECT SPLACE AS INSTITUTE,COUNT(COURSE) AS NOOFCOURS,AVG(COST) AS AVGCOSTPERCOUR
FROM STUDIES
GROUP BY SPLACE

Input:
Output:
INSTITUTE NOOFCOURS AVGCOSTPERCOUR

APPLE 1 14000

BDPS 2 27000

BITS 1 22000

BPILLANI 1 11000

COIT 1 7200

PRAGATHI 2 5600

SABHARI 5 4760

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
8. Display each Institute name with number of students

Solution:
SELECT SPLACE AS INSTITUTE,COUNT(Pname) AS NOOFSTUD
FROM STUDIES
GROUP BY SPLACE

Input:

Output:
INSTITUTE NOOFSTUD

APPLE 1

BDPS 2

BITS 1

BPILLANI 1

COIT 1

PRAGATHI 2

SABHARI 5

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
9. Display the names of male and female programmers

Solution:
SELECT pNAME AS PRNAME,SEX AS SEX
FROM PROGRAMMER
ORDER BY SEX

Input:

Output:
PRNAME SEX

JULIANA F

KAMALA F

MARY F

REBECCA F

REMITHA F

REVATHI F

VIJAYA F

NELSON M

PATRICK M

QADIR M

RAMESH M

ANAND M

ALTAF M

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
10. Display the programmer’s name and their packages

Solution:
SELECT Pname AS PRNAME,TITLE AS PACKAGE
FROM SOFTWARE
ORDER BY pNAME

Input:

Output:
PRNAME PACKAGE

ANAND PARACHUTES

ANAND VIDEO TITLING PACK

JULIANA INVENTORY CONTROL

KAMALA PAYROLL PACKAGE

MARY FINANCIAL ACC.S/W

PATRICK CODE GENERATION

QADIR READ ME

QADIR BOMBS AWAY

QADIR VACCINES
RAMESH HOTEL MANAGEMENT

RAMESH DEAD LEE

REMITHA PC UTILITIES

REMITHA TSR HELP PACKAGE

REVATHI HOSPITAL MANAGEMENT

REVATHI QUIZ MASTER

VIJAYA ISR EDITION

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
11. Display the number of packages in each language except C and C++

Solution:
SELECT COUNT(TITLE) AS NOOFPACK,DEV_IN AS LANGUAGE
FROM SOFTWARE
where DEV_IN not in('C','C++')
GROUP BY DEV_IN

Input:

Output:
NOOFPACK LANGUAGE

2 ASSEMBLY

2 BASIC

2 COBOL

2 DBASE

1 ORACLE

3 PASCAL

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
12. Display the number of packages in each language for which development cost is
less than 1000

Solution:
SELECT COUNT(TITLE) AS NOOFPACK,DEV_IN AS LANGUAGE
FROM SOFTWARE
WHERE DCOST<1000 GROUP BY DEV_IN

Input:

Output:
NOOFPACK LANGUAGE

1 C

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
13. Display the average difference between SCOST and DCOST for each language

Solution:
SELECT DEV_IN AS LANGUAGE,AVG(DCOST - SCOST) AS DIFF FROM SOFTWARE GROUP BY DEV_IN

Input:

Output:
LANGUAGE DIFF

ASSEMBLY 3875

BASIC 2250.5

C 1858.33333333333

C++ 900

COBOL 8000

DBASE 1250

ORACLE 67000

PASCAL 28767

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:
Problem Statement:
14. Display the total SCOST, DCOST and amount to be recovered for each programmer
for those
--whose DCOST has not yet been recovered

Solution:
SELECT SUM(SCOST), SUM(DCOST), SUM(DCOST-(SOLD*SCOST)) FROM SOFTWARE GROUP BY Pname
HAVING SUM(DCOST)>SUM(SOLD*SCOST)

Input:

Output:
(No column name) (No column name) (No column name)

3000 3500 3500

18000 85000 13000

4300 77100 26900

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
15. Display the highest, lowest and average salaries for those earning more than
2000

Solution:
SELECT MAX(SALARY), MIN(SALARY), AVG(SALARY)
FROM PROGRAMMER
WHERE SALARY > 2000

Input:

Output:
(No column name) (No column name) (No column name)

4500 2500 3169.23076923077

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Exercise - 4

Problem Statement:
1. Who is the most experienced programmer knowing pascal?

Solution:
SELECT (datepart(yy,GETDATE())-datepart(yy,Doj)) as EXP,pname
FROM PROGRAMMER where datepart(yy,GETDATE())-datepart(yy,Doj) in
(select max(datepart(yy,GETDATE())-datepart(yy,Doj))as EXP FROM PROGRAMMER)

Input:

Output:
EXP pname

32 NELSON

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
2. Which course has been done by most of the students?

Solution:
select course,count(pname) as total from Studies group by course

Input:

Output:
course total

DAP 2

DCA 4

DCP 1

DCS 1

HDCP 1

MCA 1

PGDCA 3

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
3. Which course has the lowest selling cost?

Solution:
select * from Studies where Cost=(select min(cost) from Studies)

Input:

Output:
Pname Splace Course Cost

ANAND SABHARI PGDCA 4500

RAMESH SABHARI PGDCA 4500

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
4. Display the courses whose fees are within 1000/- (+ or -) of the average fee

Solution:
select * from Studies where Cost=(select avg(cost) from Studies)

Input:

Output:

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
5. Who developed the package that has sold the least number of copies

Solution:
SELECT pNAME,SOLD
FROM SOFTWARE
WHERE SOLD = (SELECT MIN(SOLD) FROM SOFTWARE)

Input:

Output:
pNAME SOLD

JULIANA 0

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
6. Which language was used to develop most number of packages?

Solution:
SELECT DEV_IN FROM SOFTWARE
GROUP BY DEV_IN
HAVING MAX(DEV_IN) = (SELECT MAX(DEV_IN) FROM SOFTWARE)

Input:

Output:
DEV_IN

PASCAL

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
7. Display the names of the packages which have been sold less than the average
number of copies

Solution:
SELECT TITLE
FROM SOFTWARE
WHERE SOLD < (SELECT AVG(SOLD) FROM SOFTWARE)

Input:

Output:
TITLE

VIDEO TITLING PACK

INVENTORY CONTROL

PAYROLL PACKAGE

FINANCIAL ACC.S/W

BOMBS AWAY

VACCINES

HOTEL MANAGEMENT

TSR HELP PACKAGE

HOSPITAL MANAGEMENT

QUIZ MASTER

ISR EDITION

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
8. Who is the youngest male programmer born in 1965?

Solution:
SELECT Pname
FROM PROGRAMMER
WHERE DOB=(SELECT (MAX(DOB))
FROM PROGRAMMER
WHERE datepart(YYYY,Dob) LIKE '1965')

Input:

Output:
Pname

VIJAYA

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
9. In which year most, number of programmers born

Solution:
SELECT DISTINCT datepart(YYYY,Dob)
FROM PROGRAMMER
WHERE datepart(YYYY,dob) = (SELECT MIN(datepart(YYYY,Dob))
FROM PROGRAMMER)

Input:

Output:
(No column name)

1964

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
10. Which female programmer earning more than 3000/- does not know C, C++, ORACLE OR
DBASE

Solution:
select s.* from programmer p,software s
where p.pname=s.pname and salary>3000 and sex='F' and Dev_In not in ('C','C+
+','ORACLE','DBASE');

Input:

Output:
Pname Title Dev_In Scost Dcost Sold

REMITHA TSR HELP PACKAGE ASSEMBLY 2500 6000 6

REVATHI HOSPITAL MANAGEMENT PASCAL 1100 75000 2

REVATHI QUIZ MASTER BASIC 3200 2100 15

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
11. Which programmer has developed highest no of packages

Solution:

SELECT Pname FROM SOFTWARE


GROUP BY Pname
HAVING MAX(Pname) = (SELECT MAX(Pname) FROM SOFTWARE)

Input:

Output:
Pname

VIJAYA

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
12. Who are the male programmers earning below the average salary of female
programmers

Solution:
SELECT Pname
FROM PROGRAMMER
WHERE SEX LIKE 'M'
AND SALARY < (SELECT(AVG(SALARY)) FROM PROGRAMMER WHERE SEX LIKE 'F')

Input:

Output:
Pname

ANAND

ALTAF

NELSON

PATRICK

QADIR

RAMESH
Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
13. Display the details of those who are drawing salary.

Solution:
select a.Pname,a.salary from programmer a,programmer b where a.salary=b.salary and
a.Pname <> b.Pname

Input:

Output:
Pname salary

ANAND 3200

ALTAF 2800

JULIANA 3000

NELSON 2500
PATRICK 2800

QADIR 3000

RAMESH 3200

REBECCA 2500

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
14. Display the details of the software developed by the male programmers earning
more than 3000

Solution:
select s.*
from programmer p,software s
where p.pname=s.pname and salary>3000 and sex='m';

Input:
Output:
Pname Title Dev_In Scost Dcost Sold

ANAND PARACHUTES BASIC 399 6000 43

ANAND VIDEO TITLING PACK PASCAL 7500 16000 9

RAMESH HOTEL MANAGEMENT DBASE 12000 3500 4

RAMESH DEAD LEE PASCAL 599 4500 73

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
15. Display the details of the software developed in C by female programmers of
Pragathi

Solution:
select s.*
from programmer p,software s,studies st
where p.pname=s.pname and s.pname=st.pname and sex='f' and splace='Pragathi';

Input:
Output:
Pname Title Dev_In Scost Dcost Sold

KAMALA PAYROLL PACKAGE DBASE 9000 20000 7

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
16. How many months it will take for each programmer to recover their cost of study

Solution:
select p.Pname,CEILING(cost/salary)
from programmer p,studies s
where s.pname=p.pname;

Input:
Output:
Pname (No column name)

ANAND 2

ALTAF 3

JULIANA 8

KAMALA 2

MARY 2

NELSON 3

PATRICK 2

QADIR 5

RAMESH 2

REBECCA 5

REMITHA 2

REVATHI 2

VIJAYA 14

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
-17. Display the details of the software developed in the language which is not the
programmers first
--proficiency

Solution:
select *
from software
where dev_in in(select distinct(prof2)
from programmer
where prof2 not in(select prof1
from programmer));

Input:

Output:
Pname Title Dev_In Scost Dcost Sold

KAMALA PAYROLL PACKAGE DBASE 9000 20000 7

MARY FINANCIAL ACC.S/W ORACLE 18000 85000 4

RAMESH HOTEL MANAGEMENT DBASE 12000 3500 4

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
18. Display the details of the software developed in the language which is neither
the first nor
--second proficiency of the programmer

Solution:
select s.*
from programmer p,software s
where s.Pname=p.Pname and (dev_in <> prof1 and dev_in <> prof2);

Input:

Output:
Pname Title Dev_In Scost Dcost Sold

PATRICK CODE GENERATION COBOL 4500 20000 23

QADIR READ ME C++ 300 1200 84

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
19. Who are the programmers who joined on the same day?

Solution:
select a.pname,a.doj
from programmer a,programmer b
where a.doj=b.doj and a.pname <> b.pname;

Input:

Output:
pname doj

KAMALA 1992-01-02

REVATHI 1992-01-02

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
20. Display the programmers who are drawing same salary

Solution:
select P1.Pname,P2.Salary from Programmer P1,Programmer P2 where
p1.Salary=p2.Salary AND P1.Pname!=P2.Pname order by Salary asc

Input:

Output:
Pname Salary

NELSON 2500

REBECCA 2500

ALTAF 2800

PATRICK 2800

QADIR 3000

JULIANA 3000

ANAND 3200

RAMESH 3200

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
21. Which is the costliest package developed by a person with under 3 years of
experience

Solution:
select dev_in
from programmer p,software s
where p.pname=s.pname and dcost= (select max(s.dcost)
from programmer p, software s
where p.pname=s.pname)

Input:

Output:
dev_in

ORACLE

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
22. What is the average salary for those whose software sales value is more than
50,000

Solution:
select avg(salary)
from programmer p,software s
where p .pname=s.pname and sold*scost>50000;

Input:

Output:
(No column name)

3350

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
23. How many packages were developed by the person who developed the cheapest
package.
--Where did he / she study

Solution:
select count(*)
from programmer p,software s
where s .Pname=p.pname group by dev_in having min(dcost)=(select min(dcost) from
software);

Input:

Output:
(No column name)

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
24. How many packages developed by female programmers earning more than the highest
paid
--male programmer

Solution:
select count(dev_in)
from programmer p,software s
where s.pname=p.pname and sex='f' and salary>(select max(salary)
from programmer p,software s
where s.pname=p.pname and sex='m');

Input:

Output:
(No column name)

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
25. How many packages were developed by the most experienced programmer from BDPS

Solution:
select count(*)
from software s,programmer p
where p.pname=s.pname group by doj having max(doj)=(select max(doj)
from studies st,programmer p, software s
where p.pname=s.pname and st.pname=p.pname and (splace='bdps'));

Input:

Output:
(No column name)

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

26. Write a query to display the last name, department number, and salary of any employee
whose department number and salary both match the department number and salary of any
employee who earns a commission.

Solution:
select Ename,Deptno,sal from Emp where comm !=0

Input:

Output:
Ename Deptno sal

ALLEN 30 1600

WARD 30 1250

MARTIN 30 1250
Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

33. Write a query to display the last names of the employees who earn less than the average
salary in their departments.

Solution:
select * from emp e where sal<(select avg(sal) as avg from(select * from emp) e,
(select * from Dept) d
where e.deptno=d.Deptno
)

Input:

Output:
7369 SMITH 4 7902 1980-12-17 800 0 20

7499 ALLEN 5 7698 1981-02-20 1600 300 30

7521 WARD 5 7698 1981-02-22 1250 500 30


7654 MARTIN 5 7698 1981-09-28 1250 1400 30

7844 TURNER 5 7698 1981-09-08 1500 0 30

7876 ADAMS 4 7788 1987-05-23 1100 0 20

7900 JAMES 4 7698 1981-12-03 950 0 30

7934 MILLER 4 7782 1982-01-23 1300 0 30

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:

34. Write a query to display the last names of the employees who have one or more coworkers in
their departments with later hire dates but higher salaries.

Solution:
select * from emp where deptno in(select deptno from dept) order by sal
desc,hiredate

Input:

Output:
Empno Ename JobId Mgr Hiredate Sal Comm Deptno

7839 KING 1 1981-11-17 5000 0 10

7902 FORD 3 7566 1981-12-03 3000 0 20

7788 SCOTT 3 7566 1987-04-19 3000 0 20

7566 JONES 2 7839 1981-04-02 2975 0 20

7698 BLAKE 2 7839 1981-05-01 2850 0 30

7782 CLARK 2 7839 1981-06-09 2450 0 10

7499 ALLEN 5 7698 1981-02-20 1600 300 30

7844 TURNER 5 7698 1981-09-08 1500 0 30

7934 MILLER 4 7782 1982-01-23 1300 0 30

7521 WARD 5 7698 1981-02-22 1250 500 30

7654 MARTIN 5 7698 1981-09-28 1250 1400 30

7876 ADAMS 4 7788 1987-05-23 1100 0 20

7900 JAMES 4 7698 1981-12-03 950 0 30

7369 SMITH 4 7902 1980-12-17 800 0 20

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

35. Write a query to display the department names of those departments whose total salary cost
is above one eighth (1/8) of the total salary cost of the whole company

Solution:
select * from emp where sal >( select 0.125*sum(sal) from Emp where deptno in
(10,20,30,40))

Input:

Output:
Empno Ename JobId Mgr Hiredate Sal Comm Deptno

7839 KING 1 1981-11-17 5000 0 10

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

36. Write a query to display the last name, department number, and department name for all
employees

Solution:
select e.ename,d.deptno,d.Dname from emp e,dept d
where e.Deptno=d.Deptno

Input:

Output:
ename deptno Dname

SMITH 20 RESEARCH

ALLEN 30 SALES

WARD 30 SALES

JONES 20 RESEARCH

MARTIN 30 SALES

BLAKE 30 SALES

CLARK 10 ACCOUNTING

SCOTT 20 RESEARCH
KING 10 ACCOUNTING

TURNER 30 SALES

ADAMS 20 RESEARCH

JAMES 30 SALES

FORD 20 RESEARCH

MILLER 30 SALES

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

38. Write a query to display the employee last name, department name, location ID, and city of all
employees who earn a commission.

Solution:
select e.ename,d.Dname,d.Loc from emp e,dept d
where e.Deptno=d.Deptno and e.Comm !=0

Input:
Output:
ename Dname Loc

ALLEN SALES CHICAGO

WARD SALES CHICAGO

MARTIN SALES CHICAGO

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

39. Display the employee last name and department name for all employees who have an a
(lowercase) in their last names

Solution:
select LOWER(e.ename),d.Dname from emp e,dept d
where e.Deptno=d.Deptno
Input:

Output:
smith RESEARCH

allen SALES

ward SALES

jones RESEARCH

martin SALES

blake SALES

clark ACCOUNTING

scott RESEARCH

king ACCOUNTING

turner SALES

adams RESEARCH

james SALES

ford RESEARCH

miller SALES

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:

40. Write a query to display the last name, job, department number, and department name for all
employees who work in New York.

Solution:
select e.ename,d.Deptno,d.Dname from emp e,dept d
where e.Deptno=d.Deptno
and d.loc='NewYork'

Input:

Output:
ename Deptno Dname

CLARK 10 ACCOUNTING

KING 10 ACCOUNTING

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:

41. Display all employees including King, who has no manager. Order the results by the employee
number.

Solution:
select * from emp order by Ename

Input:

Output:
Empno Ename JobId Mgr Hiredate Sal Comm Deptno

7876 ADAMS 4 7788 1987-05-23 1100 0 20

7499 ALLEN 5 7698 1981-02-20 1600 300 30

7698 BLAKE 2 7839 1981-05-01 2850 0 30

7782 CLARK 2 7839 1981-06-09 2450 0 10

7902 FORD 3 7566 1981-12-03 3000 0 20

7900 JAMES 4 7698 1981-12-03 950 0 30

7566 JONES 2 7839 1981-04-02 2975 0 20

7839 KING 1 1981-11-17 5000 0 10

7654 MARTIN 5 7698 1981-09-28 1250 1400 30

7934 MILLER 4 7782 1982-01-23 1300 0 30

7788 SCOTT 3 7566 1987-04-19 3000 0 20

7369 SMITH 4 7902 1980-12-17 800 0 20

7844 TURNER 5 7698 1981-09-08 1500 0 30

7521 WARD 5 7698 1981-02-22 1250 500 30

Key Learnings:
Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

42. Create a query that displays employee last names, department numbers, and all the
employees who work in the same department as a given employee. Give each column an
appropriate labe

Solution:

select e.ename'Employee Name',d.Deptno 'Department No' from emp e,dept d


where e.Deptno=d.Deptno order by Dname

Input:

Output:
Employee NameDepartment No

CLARK 10

KING 10

SMITH 20

JONES 20
SCOTT 20

ADAMS 20

FORD 20

ALLEN 30

WARD 30

MARTIN 30

BLAKE 30

TURNER 30

JAMES 30

MILLER 30

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

47. Job ID and total salary for every job ID for employees who report to the same manager

Solution:
select jobid,sum(sal) as salary from emp e group by jobid
Input:

Output:
jobid salary

1 5000

2 8275

3 6000

4 4150

5 5600

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:

48. Total salary of those managers

Solution:
select mgr,sum(sal) as salary from emp e group by mgr

Input:

Output:
mgr salary

5000

7566 6000

7698 6550

7782 1300

7788 1100

7839 8275

7902 800

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:
Exercise - 5

Problem Statement:
1. Display the OrderID, CompanyName, Phone, ProductName, CityName, StateName,
--CountryName, Quantity placed by the clients whose email address is having using
--‘techmahindra.com’ domain

Solution:
select O.orderId,Cl.CompanyName,Cl.Phone,P.Productname,Cy.CityName,St.StateName from
Orders O,Clients Cl,Products P,CityMaster Cy,StateMaster St
where O.ClientID=Cl.ClientID and P.ProductID=O.OrderID and Cy.StateID=St.StateID
and Cy.CityID=Cl.CityID

Input:

Output:
orderId CompanyName Phone Productname CityName StateName

2 Zen3 8897836679 laptop Hyderabad Telangana

1 TechMahindra 8897836679 Mobile vizag AndhraPradesh

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
2. Display the sum of quantity of order for each client where the sum of quantity
range from 500
--to 1000. Along with CompanyName, Phone, CityName

Solution:
select Cl.ClientId,sum(O.quantity) from Orders O,Clients Cl group by Cl.ClientID

Input:

Output:
ClientId (No column name)

795371 3

795372 3

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
3. Display OrderID, CompanyName, Phone, ProductName whose product name is starting
with ‘M’

Solution:
select O.orderId,Cl.CompanyName,Cl.Phone,P.Productname from
Orders O,Clients Cl,Products P where O.ClientID=Cl.ClientID and
P.ProductID=O.OrderID and P.ProductName like 'M%'

Input:

Output:
orderId CompanyName Phone Productname

1 TechMahindra 8897836679 Mobile

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
4. Display the total quantity of order for each cityid

Solution:
select sum(O.quantity) from Orders O,Clients Cs where
O.ClientID=Cs.ClientID
group by Cs.CityID

Input:

Output:
(No column name)

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
5. Create a view which displays all those orders whose Product Unit Price range
between 2000 to
--3000

Solution:
select O.* from Orders O ,Products P where O.ProductID=P.ProductID and P.UnitPrice
between 2000 and 3000

Input:

Output:
OrderID OrderDate ClientID ProductID Quantity ShippingDate

1 2021-12-07 00:00:00 795371 1 1 2021-12-08 00:00:00

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
-6. Display Orders placed by the clients whose email address is created using
‘techmahindra.com’
--domain

Solution:
select O.* from Orders O,Clients C where O.ClientID=C.ClientID and email
like'___________techmahindra.com'

Input:

Output:
OrderID OrderDate ClientID ProductID Quantity ShippingDate

1 2021-12-07 00:00:00 795371 1 1 2021-12-08 00:00:00

2 2021-12-08 00:00:00 795372 2 2 2021-12-09 00:00:00

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
7. Display Orders placed by the clients who are located in the country name ‘India’

Solution:
select O.* from
Orders O,Clients Cl,Products P,CityMaster Cy,StateMaster St,CountryMaster CM
where O.ClientID=Cl.ClientID and P.ProductID=O.OrderID and Cy.StateID=St.StateID
and Cy.CityID=Cl.CityID and st.CountryID=CM.CountryID
and CM.CountryName like 'India'

Input:

Output:
OrderID OrderDate ClientID ProductID Quantity ShippingDate

1 2021-12-07 00:00:00 795371 1 1 2021-12-08 00:00:00

2 2021-12-08 00:00:00 795372 2 2 2021-12-09 00:00:00

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
8. Display Orders placed by the clients whose city name is starting with ‘H’

Solution:
select O.* from Orders O,Clients cs,CityMaster CM
where O.ClientID=cs.ClientID and cs.CityID=cm.CityID and Cm.CityName like 'H%'

Input:

Output:
OrderID OrderDate ClientID ProductID Quantity ShippingDate

2 2021-12-08 00:00:00 795372 2 2 2021-12-09 00:00:00

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
9. Display all those products whose ReorderLevel range is not in 50 to 100

Solution:
select * from Products where ReorderLevel not between 50 and 100

Input:

Output:
ProductID ProductName UnitPrice LincensesInHand ReorderLevel

1 Mobile 3000.00 101 34

2 laptop 25000.00 102 1

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
10. Display the average quantity of order for each product where the average
quantity is greater
--than 20

Solution:
select avg(O.Quantity) from Orders O where O.Quantity>20 group by ClientId

Input:

Output:

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
11. Display all those orders whose product name is having ‘studio’ word in them

Solution:
select o.* from Orders o,Products p where o.ProductID=p.ProductID and p.ProductName
like '%studio%'

Input:

Output:
OrderID OrderDate ClientID ProductID Quantity ShippingDate

3 2021-12-04 00:00:00 795373 3 5 2021-12-05 00:00:00

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
12. Display the sum of quantity of order for each client where the sum of quantity
range from 500
--to 1000

Solution:
select cl.ClientId,cl.contactperson,sum(o.quantity) from Orders o,Products p,Clients
cl where o.ProductID=p.ProductID and cl.ClientID=o.ClientID
and p.UnitPrice>=500 and p.UnitPrice<=1000 group by cl.ClientID,cl.ContactPerson

Input:

Output:
ClientId contactperson(No column name)

795374 mark 10

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
13. Display all the Clients who are located in the city having city description as
“Garden City ”

Solution:
select cl.ClientId,cl.contactperson,cm.CityName from Clients cl,CityMaster cm where
cl.CityID=cm.CityID and cm.CityDesc='garden city'

Input:

Output:
ClientId contactpersonCityName

795373 satya bangalore

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:
14. Display all the Clients who are located outside country name India

Solution:
select cl.*,com.CountryName from Clients cl,CityMaster cm,StateMaster
sm,CountryMaster com where cl.CityID=cm.CityID and sm.CountryID=com.CountryID
and cm.StateID=sm.StateID and com.CountryName='Usa'

Input:

Output:
ClientID CompanyName ContactPersonPhone EMAIL CityID CountryName

795374 facebook mark 8426520453 mz39795374@facebook.com c4


Usa

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Problem Statement:
15. Display all those orders whose Product Unit Price range between 2000 to 3000

Solution:
select o.* from Orders o,Products p where p.UnitPrice>=2000 and p.UnitPrice<=3000

Input:

Output:
OrderID OrderDate ClientID ProductID Quantity ShippingDate

1 2021-12-07 00:00:00 795371 1 1 2021-12-08 00:00:00

2 2021-12-08 00:00:00 795372 2 2 2021-12-09 00:00:00

3 2021-12-04 00:00:00 795373 3 5 2021-12-05 00:00:00

4 2021-12-06 00:00:00 795374 4 10 2021-12-07 00:00:00

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:
Exercise - 6

Problem Statement:
1. Create a view which displays the city details with the following columns
--CityID, CityName, CityDescription, StateName, StateDescription, CountryName,
--CountryDescription

Solution:
create view vw_citystatecountry
as
select
cm.CityID,cm.CityDesc,sm.StateName,sm.StateDesc,com.CountryName,com.CountryDesc from
CityMaster cm,StateMaster sm,CountryMaster com
where cm.StateID=sm.StateID and com.CountryID=sm.CountryID;

Input:
select * from vw_citystatecountry

Output:
CityID CityDesc StateName StateDesc CountryName CountryDesc

c1 smart city AndhraPradeshTelugu PeopleIndia Multiculture

c2 Metro Telangana TeluguPeople India Multiculture

c3 garden city Karnataka kanada peopleIndia Multiculture

c4 vibrant city washington english people Usa RichestCountry

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
2. Create a view which displays cities details belongs to the country ‘India’

Solution:
create view vw_cityindia
as
select cm.* from CityMaster cm,StateMaster sm,CountryMaster com
where cm.StateID=sm.StateID and com.CountryID=sm.CountryID and
com.CountryName='India'

Input:
select * from vw_cityindia

Output:
CityID CityName CityDesc StateID

c1 vizag smart city s1

c2 Hyderabad Metro s2

c3 bangalore garden city s3

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:
3. Create a stored procedure which takes the city name and displays all the orders
placed by the

--clients located in that given city name. If city name is not passed to that
procedure, it must display
--all those orders placed by the clients located in the city name starting with ‘N’.

Solution:
create procedure sp_cityname(@cityname varchar(50))
as
begin
if @cityname is not null
begin

select o.* from orders o,clients cl,CityMaster cm where cl.CityID=cm.CityID


and cl.ClientID=o.ClientID and CityName=@cityname
end
else
begin
select o.* from orders o,clients cl,CityMaster cm where cl.CityID=cm.CityID
and cl.ClientID=o.ClientID and CityName like 'N%'
end
end

Input:
exec sp_cityname 'vizag'

Output:
OrderID OrderDate ClientID ProductID Quantity ShippingDate
1 2021-12-07 00:00:00 795371 1 1 2021-12-08 00:00:00

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
-4. Create a stored procedure which displays the list of trigger names created on
the given table. If
--there are no triggers available on the given table, display ‘No triggers available
on
--<table_name>’

Solution:
create procedure sp_distrigger
as
begin
if exists(SELECT * FROM sys.triggers
)

SELECT
name,
is_instead_of_trigger
FROM
sys.triggers
WHERE
type = 'TR';
else
print 'no triggers'
end

Input:
exec sp_distrigger

Output:
no triggers

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
5. Create a procedure which displays the orders (along with CompanyName,
ProductName,
--UnitPrice, CityName) placed in the given range of dates.

Solution:
create procedure sp_disporders
as
begin
select o.*,cl.CompanyName,p.ProductName,p.unitprice,cm.cityname from Orders
o,Clients cl,Products p,CityMaster cm
where o.ProductID=p.ProductID and cl.ClientID=o.ClientID and cl.CityID=cm.CityID
order by OrderDate
end

Input:
exec sp_disporders

Output:
OrderID OrderDate ClientID ProductID Quantity ShippingDate
CompanyName ProductName unitprice cityname

3 2021-12-04 00:00:00 795373 3 5 2021-12-05 00:00:00


microsoft visualstudio 100000.00 bangalore

4 2021-12-06 00:00:00 795374 4 10 2021-12-07 00:00:00


facebook books 500.00 new york

1 2021-12-07 00:00:00 795371 1 1 2021-12-08 00:00:00


TechMahindra Mobile 3000.00 vizag

2 2021-12-08 00:00:00 795372 2 2 2021-12-09 00:00:00


google laptop 25000.00 Hyderabad

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:


Completed Date:

Problem Statement:

6. Create a function which takes the table name and returns the number of check constraints
create in it. If no check constraints available in that table then return 0

Solution:

CREATE FUNCTION udf_chk (


@tablename varchar(max)
)
RETURNS TABLE
AS
RETURN
SELECT *
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE
TABLE_NAME = @tablename;

Input:
select * from udf_chk('Products')

Output:
TechDB dbo PID_PK TechDB dbo Products PRIMARY KEY NO NO

TechDB dbo PName_UQ TechDB dbo Products UNIQUE NO NO

TechDB dbo LIH_CK TechDB dbo Products CHECK NO NO

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)
Time Taken for this exercise:

Completed Date:

Problem Statement:

7. Create a function which takes ProductName and Discount percentage and returns the UnitPrice
based on the discount percentage. Same function has to ensure whether the product exists or
not. If product exist return the UnitPrice based on the discount percentage else return zero.

Solution:
CREATE FUNCTION dbo.fnproducts(@productname varchar(max))
RETURNS varchar(max)
AS
BEGIN
DECLARE @tmp varchar(max)
IF (@productname is not null )
select @tmp=unitprice from Products where ProductName=@productname
ELSE
SELECT @tmp = 0
RETURN @tmp
END

Input:
print dbo.fnproducts('mobile')

Output:
3000.00

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

8. Create a trigger which accepts Orders from users only between 9 AM and 6 PM

Solution:
CREATE TRIGGER Orders_trg_after ON Orders

After Insert,update,delete
AS
Begin

DECLARE @Dt int


Set @dt=DATEPART(HH,Getdate())
If (@Dt Not Between 9 AND 17 )
Begin
print('C annot Perform')
RollBack
End
End

Input:

Output:
---------------------------
Microsoft SQL Server Management Studio

---------------------------

No row was updated.

The data in row 5 was not committed.

Error Source: .Net SqlClient Data Provider.

Error Message: The transaction ended in the trigger. The batch has been aborted.

C annot Perform

Correct the errors and retry or press ESC to cancel the change(s).

---------------------------

OK Help

---------------------------

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:
9. Create a database trigger which allows users to create, alter, drop objects between 9 AM and 6
PM

Solution:
CREATE TRIGGER ddl_trig_database
ON ALL SERVER
FOR CREATE_TABLE
AS

Begin

DECLARE @Dt int


Set @dt=DATEPART(HH,Getdate())
If (@Dt Not Between 9 AND 17 )
Begin
print('C annot Perform')
RollBack
End
End

GO

--select * from sys.server_triggers

--DROP TRIGGER ddl_trig_database


--ON ALL SERVER

Input:

Output:
Msg 3609, Level 16, State 2, Line 23
The transaction ended in the trigger. The batch has been aborted.

Completion time: 2021-12-12T18:43:44.3543235+05:30

Problem Statement:

10. Remove the Check constraint created on Order Date column, which checks whether the given
Order Date is greater or equal to Current Date.

Solution:
ALTER TABLE Orders
DROP CONSTRAINT SDate_CK;

Input:

Output:

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

11. Create a rule with a name ‘OrderDate_Rule’ with a rule that given date is greater than or equal
to current date. Apply the same to Orders table

Solution:
alter table orders
add constraint OrderDate_ck check (OrderDate>getdate())
Input:

Output:

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

12. Write the syntax for applying Rule to the columns while creating table

Solution:
-- Simple CREATE TABLE Syntax (common if not using options)
CREATE TABLE
{ database_name.schema_name.table_name | schema_name.table_name |
table_name }
( { <column_definition> } [ ,...n ] )
[ ; ]

Input:

Output:

Key Learnings:

Challenges faced & rectification efforts:


Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

13. How to display the user defined rules created in DB using query window?

Solution:
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS

Input:

Output:

Key Learnings:

Challenges faced & rectification efforts:

Description Efforts Status


(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

14. What is DEFAULT object in SQL Server?

Write the syntax for binding a default to column while creating table

Solution:

Creates an object called a default. When bound to a column or an alias data type, a default
specifies a value to be inserted into the column to which the object is bound (or into all
columns, if of an alias data type), when no value is explicitly supplied during an insert.

CREATE TABLE dbo.doc_exz (


column_a INT,
column_b INT DEFAULT 50);

Input:

Output:
Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

Problem Statement:

15. How to display the user defined function names created in DB using query window?

Solution:
SELECT sm.object_id,
OBJECT_NAME(sm.object_id) AS object_name,
o.type,
o.type_desc,
sm.definition,
sm.uses_ansi_nulls,
sm.uses_quoted_identifier,
sm.is_schema_bound,
sm.execute_as_principal_id
-- using the two system tables sys.sql_modules and sys.objects
FROM sys.sql_modules AS sm
JOIN sys.objects AS o ON sm.object_id = o.object_id
-- from the function 'dbo.ufnGetProductDealerPrice'
WHERE sm.object_id = OBJECT_ID('dbo.fn_constraint')
ORDER BY o.type;
GO

Input:
Output:
object_id object_name type type_desc definition uses_ansi_nulls
uses_quoted_identifier is_schema_bound execute_as_principal_id

1893581784 fn_constraintFN SQL_SCALAR_FUNCTION Create FUNCTION


fn_constraint ( @tablename varchar(50) ) RETURNS varchar(100) -- or
whatever length you need AS BEGIN Declare @logid varchar(max);
SELECT @logid = 'SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS where
TABLE_NAME= @tablename' RETURN @logid END 1 1 0 NULL

Key Learnings:

Challenges faced & rectification efforts:

Status
Description Efforts
(Solved/Not solved)

Time Taken for this exercise:

Completed Date:

You might also like