SQL Queries For Practice - Advanced SQL Queries PDF
SQL Queries For Practice - Advanced SQL Queries PDF
SQL Queries For Practice - Advanced SQL Queries PDF
chaltum.com (Avinash Malhotra, IIT Alumni, 8+ Exp). Both Online and Classroom Tr
https://tutorial.techaltum.com/sql-queries-for-practice.html 1/15
10/20/2020 sql queries for practice | advanced sql queries
Table :- EmpDept
Schema:-
create table empdept(deptid varchar(50) primary key,deptname varchar(100), dept_off varchar(100), d
references employee(empid))
Table :- EmpSalary
103 5000 No
Schema:-
create table empsalary(empid int foreign key references employee(empid), salary bigint, ispermanent
https://tutorial.techaltum.com/sql-queries-for-practice.html 2/15
10/20/2020 sql queries for practice | advanced sql queries
Ads by
Tech Altum Tutorial
Send feedback Why this ad?
Table :- Project
ProjectId Duration
p-1 23
p-2 15
p-3 45
p-4 2
p-5 30
Schema:-
create table project(projectid varchar(50) primary key, duration int)
Table :- Country
cid cname
c-1 India
c-2 USA
c-3 China
c-4 Pakistan
https://tutorial.techaltum.com/sql-queries-for-practice.html 3/15
10/20/2020 sql queries for practice | advanced sql queries
c-5 Russia
Tech Altum Tutorial
Schema:-
create table country(cid varchar(50) primary key, cname varchar(100))
Table :- ClientTable
Schema:-
create table clienttable(clientid varchar(50) primary key, clientname varchar(100), cid varchar(50)
country(cid))
Table :- EmpProject
Schema:-
create table empproject(empid int foreign key references employee(empid), projectid varchar(50) for
project(projectid), clientid varchar(50) foreign key references clienttable(clientid),startyear int
https://tutorial.techaltum.com/sql-queries-for-practice.html 4/15
10/20/2020 sql queries for practice | advanced sql queries
Ads by
Tech Altum Tutorial
Send feedback Why this ad?
Perform-to-animate
2D Cartoons
Use motion capture to interact
with audience and scene
elements during live show.
Cartoon Animator
Queries:-
Simple Queries
1. Select the detail of the employee whose name start with P.
https://tutorial.techaltum.com/sql-queries-for-practice.html 5/15
10/20/2020 sql queries for practice | advanced sql queries
Ads by
Send feedback Why this ad?
4. Select the details of the employee who work either for departm
102.
or
https://tutorial.techaltum.com/sql-queries-for-practice.html 6/15
10/20/2020 sql queries for practice | advanced sql queries
5. Tech
What is the department name for DeptID E-102?
Altum Tutorial
https://tutorial.techaltum.com/sql-queries-for-practice.html 7/15
10/20/2020 sql queries for practice | advanced sql queries
10. How many project started and finished in the same year.
11. select the name of the employee whose name's 3rd charactor
https://tutorial.techaltum.com/sql-queries-for-practice.html 8/15
10/20/2020 sql queries for practice | advanced sql queries
Nested Queries
1. Select the department name of the company which is assigned
whose employee id is grater 103.
select deptname from empdept where deptid in (select department from employee where empid>103)
output:-
https://tutorial.techaltum.com/sql-queries-for-practice.html 9/15
10/20/2020 sql queries for practice | advanced sql queries
select empname from employee where empheadid =(select empid from employee where empname='abhishek')
output:-
select empname from employee where empid =(select depthead from empdept where deptname='hr')
output:-
select empname from employee where empid in(select empheadid from employee) and empid in(select emp
ispermanent='yes')
output:-
https://tutorial.techaltum.com/sql-queries-for-practice.html 10/15
10/20/2020 sql queries for practice | advanced sql queries
5. Select the name and email of the Dept Head who is not Perma
select empname, emaildid from employee where empid in(select depthead from empdept ) and empid in(s
empsalary where ispermanent='no')
output:-
select * from employee where department in(select deptid from empdept where dept_off='monday')
output:-
https://tutorial.techaltum.com/sql-queries-for-practice.html 11/15
10/20/2020 sql queries for practice | advanced sql queries
select * from clienttable where cid in(select cid from country where cname='india')
output:-
select * from employee where department in(select deptid from empdept where deptname='development')
output:-
https://tutorial.techaltum.com/sql-queries-for-practice.html 12/15
10/20/2020 sql queries for practice | advanced sql queries
Video
TechTutorial for Basic SQL Queries
Altum Tutorial
https://tutorial.techaltum.com/sql-queries-for-practice.html 13/15
10/20/2020 sql queries for practice | advanced sql queries
7. R language
8. Video Tutorial
Tutorial.techaltum.com is run and maintained by Tech Altum, IT Training Institute in Noida (An IIT
Alumni Institute).
For Video Tutorials, Subscribe our Youtube Channel. Tech Altum Youtube Channel.
https://tutorial.techaltum.com/sql-queries-for-practice.html 15/15