0% found this document useful (0 votes)
23 views13 pages

Mock

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views13 pages

Mock

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

• 1.

Perform calculation on sales from 1 previous , current and 2 next


value

• 2. Perform calculation on sales from 3 previous , current and 2 next


value
a)
b)
3. For the following relation schema:
• Table 1 : employee(employee-name, street, city)
• Table 2 : works(employee-name, company-name, salary)
• Table 3 : company(company-name, city)
• Table 4 : manages(employee-name, manager-name)

• Give an expression in SQL for each of the following queries:

a) Find the names, street address, and cities of residence for all employees
who work for 'First Bank Corporation' and earn more than $10,000.
a) select e.employee_name, e.street, e.city FROM
employee e
join
works w on e.employee_name = w.employee_name
where
w.company_name = 'First Bank Corporation'
and w.salary > 10000;
b) Find the names of all employees in the database who live in the same cities as the
companies for which they work

select
e.employee_name from employee e
join
works w on e.employee_name = w.employee_name
join
company c on w.company_name = c.company_name
where
e.city = c.city;
c) Find the names of all employees in the database who live in the same cities and on the same streets as do their managers.

select
e.employee_name from employee e
join
manages m on e.employee_name = m.employee_name
join
employee mgr on m.manager_name = mgr.employee_name
where
e.city = mgr.city and e.street = mgr.street;
4 Create foreign key on
Department Employee
5 Create foreign key on student id in
Library
Student Library:
:
student_id student_name student_branch student_emailid

100 Riya CSE [email protected] book_id student_id number_of_books_borrowed

101 Aman CSE [email protected]


200 100 9
102 Deepak Mech [email protected]
201 101 15

202 102 7
103 Barkha IT [email protected]
203 103 0
5)

create table students (


student_id int primary key,
student_name varchar(10),
student_branch varchar(10),
student_emailid varchar(10)
);

create table library (


book_id int primar key,
student_id int,
number_of_books_borrowed int,
foreign key (student_id) references students(student_id)
);
6. Get the output using table
partition_by_ground_yr_ind_orde
6)
7. Get the output using table
partition by ground wise rank

You might also like