100% found this document useful (1 vote)
987 views10 pages

MIS 2100 HW Minor - Basic SQL Queries (Spring 2020)

1. The document provides the primary key fields for various tables in a database including Customer (CustID), Product (ModelID), etc. 2. SQL queries are provided that retrieve data from the database tables based on various criteria. For example, one query retrieves the name and headquarters city for each region ordered alphabetically by region name. Another query shows state name and population for states over 8 million ordered by population. 3. For each query, the problem number, SQL statement, and first 10 rows of output are displayed (or less if fewer than 10 rows are returned). The queries filter and sort data from the tables to meet the specified output requests.

Uploaded by

Cesar Flores
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
987 views10 pages

MIS 2100 HW Minor - Basic SQL Queries (Spring 2020)

1. The document provides the primary key fields for various tables in a database including Customer (CustID), Product (ModelID), etc. 2. SQL queries are provided that retrieve data from the database tables based on various criteria. For example, one query retrieves the name and headquarters city for each region ordered alphabetically by region name. Another query shows state name and population for states over 8 million ordered by population. 3. For each query, the problem number, SQL statement, and first 10 rows of output are displayed (or less if fewer than 10 rows are returned). The queries filter and sort data from the tables to meet the specified output requests.

Uploaded by

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

Cesar Flores

A01628585
MIS 2100 Homework (Minor)
Basic SQL SELECT Queries
Assignment
Part A
1. For each of the tables in the database, identify the name of the Primary Key field (for
each, list both the table name as well as the corresponding primary key). (10 points)

Tables Primary Key


Customer CustID
Product ModelID
OrderLine OLID
Region RegionID
SalesOrder SOID
Service SvcID
USState StateID

Part B
For problems 2-10, complete queries for each of the output requests. For each query,
include (a) the problem number (2-10), (b) the text of your SQL query, and (c) the
output of the query (if the query returns more than 10 lines, include only the first 10
lines of output). (10 points each)
2. Output all records and all fields contained within the Product table. Your query
should not list all field names in the SELECT clause.
3. Output the name of each region as well as the city where the sales headquarters is
for that region. Your output should include only these two fields and should be
ordered alphabetically by the name of the region.

2
4. Output the state name and 2016 population for every state with a population of at
least 8 million. Order the output from largest state (by population) to smallest.

3
5. Show the state name and population for each state with a population greater than 5
million that starts with the letter N. Order your output alphabetically by state name.

4
6. Output the first name, number of children, and pet status (y or n) for all customers
that have both children and pets and live in Colorado (CO). Order results by number
of children, from highest to lowest.

5
7. For each customer who lives in Arizona (AZ), how many children would they have
if they had triplets tomorrow? Your output should show the customer’s first and last
name, their state code, their current number of children, and the number of children
after triplets (which should be labeled “KidsPlus”). Order the output from most
post-triplet children to fewest.

6
8. The company is considering lowering the price (MSRP) by 15% on its models that
are currently listed for over $450 (excluding the RapidBunny model). Write a query
that shows the names of these models (be sure to exclude the RapidBunny), their
current prices, and what the price would be if it were discounted by 15%. Order
your output alphabetically by model name.

7
9. Show the order total, order ID, and date for each order that was placed on August
14th, 15th, and 16th. Do not use AND in your WHERE clause. Order your results first
by date (earliest to latest) and then by order value (from highest to lowest).

8
10. Output the first name, last name, and state (use CustState) for any customer that has
either kids or pets (or both) but is not married. Order you results alphabetically by
last name and include in your output any fields that would help someone (e.g., your
boss) feel comfortable that your output is correct.

9
10

You might also like