P. 1
SQL PRIMER

SQL PRIMER

|Views: 6|Likes:
Published by mansha99
SQL Queries
SQL Queries

More info:

Published by: mansha99 on Feb 02, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

04/20/2014

pdf

text

original

Lab-1

Find the names of all employees who work for First Bank Corporation.

and cities of residence of all employees who work for First Bank Corporation and earn more than $10. street address. . Find the names.Find the names and cities of residence of all employees who work for First Bank Corporation.000 per annum.

. Find the names of all employees who live in the same city and on the same street as do their managers.Find the names of all employees in this database who live in the same city as the company for which they work.

Find all companies located in every city in which Small Bank Corporation is located.Find the names of all employees in this database who do not work for First Bank Corporation. Assume the companies may be located in several cities. Find the names of all employees who earn more than every employee of Small Bank Corporation. .

. Find the company with the smallest payroll.Lab-2 Find the company with the most employees.

. than the average salary at First Bank Corporation.Find those companies whose employees earn a higher salary. on average.

person
 where accident.cidents in 1989.report-number = participated.report-number and participated.driver-id
 and date between date ’1989-00-00’ and date ’1989-12-31’ .Lab-3 Find the total number of people who owned cars that were involved in ac. Select count (distinct name)
 from accident.driver-id = person. participated.

name = ’Jones’ and p.driver-id and person. car c
 where p.license and c. assume any values for required attributes. select count (distinct *) from accident
 where exists (select *
 from participated.report-number = participated. 4007.Find the number of accidents in which the cars belonging to “John Smith” were involved.license. c.report-number) Add a new accident to the database. ’2001-09-01’. ’Berkeley’) insert into participated
 select o. insert into accident values (4007. person
 where participated.license = c. 3000
 from person p.driver-id = o.driver-id and o. owns o.name = ’John Smith’
 and accident.driver-id.driver-id = person.model = .

owns o
 where p.driver-id = o.driver-id) 
 Update the damage amount for the car with license number“AABB2000” in 
the accident with report number “AR2197” to $3000. delete car
 where model = ’Mazda’ and license in 
 (select license
 from person p.’Toyota’ Delete the Mazda belonging to “John Smith”. 
 update participated
 set damage-amount = 3000
 where report-number = “AR2197” and driver-id in 
 (select driver-id
 from owns
 where license = “AABB2000”) .name = ’John Smith’ and p.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->