SQL Practice Questions: Employee and Store Database, Assignments of Introduction to Database Management Systems

Sql practice questions based on an employee and store database. The questions involve selecting employee names, store sales, and performing updates and inserts. The database includes columns for employee last name, first name, date of birth, store code, store name, store ytd sales, region code, and region description.

Typology: Assignments

Pre 2010

Uploaded on 02/10/2009

koofers-user-6m3-1
koofers-user-6m3-1 🇺🇸

5

(1)

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Practice SQL questions based on store database page 95 of textbook
1. List the last and first names of all employees whose age is >40 years.
Select emp_lname, emp_fname
From employee
Where emp_dob < #11/20/1961#;
emp_lname emp_fname
Greenboro Lottie
Smith Robert
Ogallo Roberto
Eindsmar Jack
Archialo Barry
2. List the last and first names of all employees who work in stores that have made
more than $1,000,000.00 in YTD sales, sorted by employee last name.
Select emp_fname, emp_lname
From employee, store
Where store_ytd_sales > 1000000
And store.store_code = employee.store_code
order by emp_lname;
emp_fname emp_lname
Barry Archialo
Jack Eindsmar
Elizabeth Johnsson
Robert Mckee
Howard Olenko
Nancy Ratula
Cary Renselaer
Jennie Rumpersfro
Alan Washington
3. List the total sales of all stores in the West region
Select store_ytd_sales
From store, region
Where region.region_descript = “West”
And region.region_code = store.region_code;
store_ytd_sales
$1,003,455.76
$1,421,987.39
$944,568.56
pf3
pf4

Partial preview of the text

Download SQL Practice Questions: Employee and Store Database and more Assignments Introduction to Database Management Systems in PDF only on Docsity!

Practice SQL questions based on store database page 95 of textbook

1. List the last and first names of all employees whose age is >40 years.

Select emp_lname, emp_fname

From employee

Where emp_dob < #11/20/1961#;

emp_lname emp_fname Greenboro Lottie Smith Robert Ogallo Roberto Eindsmar Jack Archialo Barry

2. List the last and first names of all employees who work in stores that have made

more than $1,000,000.00 in YTD sales, sorted by employee last name.

Select emp_fname, emp_lname

From employee, store

Where store_ytd_sales > 1000000

And store.store_code = employee.store_code

order by emp_lname;

emp_fname emp_lname Barry Archialo Jack Eindsmar Elizabeth Johnsson Robert Mckee Howard Olenko Nancy Ratula Cary Renselaer Jennie Rumpersfro Alan Washington

3. List the total sales of all stores in the West region

Select store_ytd_sales

From store, region

Where region.region_descript = “West”

And region.region_code = store.region_code;

store_ytd_sales $1,003,455. $1,421,987. $944,568.

STORE_CODE STORE_NAME STORE_YTD_SALES REGION_CODE EMP_CODE

4 Attribute Alley $802,883.28 2 3 5 Primary Key Point $2,930,098.45 1 15

9. Add a new sixth store whose name is ‘Foreign Keystone’. This is will be store 6.

We have not yet decided in which region it will be located or who will be its

manager. Then display the entire contents of the store table.

Insert into store

Values ("6","Foreign Keystone",0,null,null);

Select *

From store;

STORE_CODE STORE_NAME STORE_YTD_SALES REGION_CODE EMP_CODE

1 Access Junction $1,003,455.76 2 8 2 Database Corner $1,421,987.39 2 12 3 Tuple Charge $986,783.22 1 7 4 Attribute Alley $802,883.28 2 3 5 Primary Key Point $2,930,098.45 1 15 6 Foreign Keystone $0.

10. How many employees have no middle initial.

Select count (*)

From employee

Where emp_initial is null;

Expr 2