Você está na página 1de 8

INLS161.003.

FA15 Database Assignment 5


Required Queries
Imagine that the independent bookstore owner who hired you
to create an inventory and sales database asks you to create
queries for each of the following questions or requests. The
first 5 queries youll create could be considered basic
queries, while 6-14 become more complex, requiring a bit
more effort. Please follow these guidelines when completing
this portion of assignment 5:
Save each using the qryNN naming convention, or with a short form of
the actual question appended if you wish
For example, the first query should be saved as qry01
Or, if you prefer to be more explicit, qry01:Where are our
publishers located?
For the queries in this task,
All sorts based on text are ascending
All sorts based on numbers are descending
Be sure to put a sort on every value that you use in a query, but pay
attention to the order in which the query will sort the values.
01. Get me a list of our publishers and, oh yes, I need to know
where they are located.
One table, three values
Show the names of all of the publishers, their states and/or their
countries.
Sort the results in this order:
1. Country
2. State
3. Name of the publisher

02. We want to spread around our purchases. If I tell you a


state, can you tell me what publishers we deal with in that
state?
One table, two values, one with a parameter criteria
This is a question about US publishers, so use a filter on the country
field to weed out any publishers who may not have a location in a US
state and a parameter criteria on the state field to select the specific
state

The parameter should permit the user to enter the state


abbreviation in the query, remembering that the states are
stored in two letter abbreviations

Use your parameter instructions to guide the user to understand


what values to enter into the parameter dialog box

Show the names of all of the publishers who are in a certain state.
Display only the name, not the state or the country, because the
parameter will be the state.
Sort by the name of the publisher.
03. I wonder how many university-affiliated publishers we deal
with. Let me see a list of all of them, sorted by where they are.
One table, four values, one with a criteria that calls for a
wildcard
Show name, city, state, and country fields in the Publishers table for
those publishers who have the word university as part of their name

Remember, the word university can be anywhere in a name

Make your parameter so that it will return all records that have
the word university as part of the name

You may need to use a wildcard character, and perhaps use it in


more than a single location

Sort the results in this order


1. Country
2. State
3. Name of the publisher

04. I was just asked about that guy Prinz or Prince or Prens,
but I can't remember how his name is spelled? While you're at
it, make the query so that we can use it each time we need to
find any authors whose names start with the same letters.
One table, one value, one with a parameter criteria that calls
for a wildcard
Use a parameter query to show the names of all of those authors
whose last names begin in the same fashion. This query can pull
names that begin with any series of letters; they don't have to begin
with PR.
Sort by author last name.
05. We have books in different languages, but how many titles
do we have in each language? Let's start by finding out the
books for which we have more than two copies, but only the
titles of the books that are in German. We need to see the
number of copies, the name of the book, and the name of the
publisher.
Two tables, three values, two with a criteria, and a Boolean
(AND/OR) decision to make
Create a list of titles for which we have more than two copies in stock,
but only show us those titles that are in German.
This is a touch more complex. You will need more than a single table
for this one, and this time your criteria needs to return values that
meet two different criteria
1. A more than criteria
2. AS WELL AS a specific criteria
Sort the results in this order:
1. Number of copies
2. Name of the book
3. Name of the publisher

06. Are we spending too much money on cheap books? We


need a list of the titles (just the titles) of all the books whose
retail price is less than $10, but only those titles for which we
possess more than 1 copy. Sort the titles by the number we
have in stock, but make sure the titles are arranged
alphabetically.
One table, three values (but only one will show), two with a
criteria, and a Boolean (AND/OR) decision to make
You need to query on a criteria that will not be displayed in the result i.e., we don't need to see the price or the number of books

Show only the names of all of those books that have a retail price
below a certain amount AND that have the number of books in
stock greater than a certain number

Your resultant table will be sorted first by a field that will not be
displayed (books costing less than $10, but only those where the
value in the number of copies is greater than 1) and secondarily
sorted by a field that will be displayed (the titles of the books
that meet the first criteria)

Sort the results in this order:


1. Number of copies, but do not show this value in the results
2. Title
07. Oops, I got that wrong. I meant to say that we want to
know the titles of all the books designated as cheap as well as
the titles of all the books that we have more than one copy of,
whether they were cheap or expensive. This time we need to
see both the number and the titles, by number first and title
second.
One table, three values (but only two will show), two with a
criteria, and a Boolean (AND/OR) decision to make
Show the names of all of those books that have a price below a certain
amount OR that have the number of books in stock greater than a
certain number. Show the titles and the number of books in stock.
This one is similar to query 06, but here you need to use two criteria
with an OR operation. Pay attention to what needs to show in the
resultant table.
Sort the results in this order:

1. Number of copies
2. Title
08. My hearing is going and sometimes I can't quite distinguish
the difference in the pronunciation of words that begin with B
from words that begin with P. Thus, when someone asks about
our books, I am not sure I understand which one they are
asking for so I need a list of both possibilities. While you're at
it, make it so that I can call up books that begin with either of
any two letters.
One table, one value, with a two part parameter query and a
Boolean (AND/OR) decision to make about the two parameters
Use a multi-part parameter query to do this one.
Single table simple select, but you need to use a two criteria
parameter query to make it truly dynamic, so that you can pull
results according to the letters you enter as you ask the question
Show the titles of all of those books whose title begins with
either of two letters (set the parameter so that it will return
values for any two letters that are entered into the parameter;
don't restrict it to only B and P)
Sort the dataset that is returned by title.
09. What states are our publishers in and how many publishers
are in each state? I don't need the names of the publishers; I
just need the number in each state. But I do need to see them
sorted by the number in each state with the largest number
first.
One table, three values - two from a field, one created from a
field, one with a totals criteria
Now you start to add the use of functions to manipulate the results
1. This requires opening the Totals () field in the QBE grid
2. Show a count of the number of publishers in each state
o You need to add a criteria that will eliminate all records
that have no value in the state field from being counted
Sort the results in this order:
1. Count of publishers
2. State

10. The fire insurance people need to know how much our book
stocks are worth. We need a list of the replacement costs for
each our books. They don't need to know the individual cost or
the number of copies we have, but they do want to see the
replacement costs from largest to smallest, to include the
titles of the books that will need replacing.
One table, two values - one from a field, one created with a
built function
For each book, show:
The book title and the total monetary value of that stock of that
particular book
Call this field Total Value and format it to display as currency
More functions, but instead of using a function on the results of a
select query, you now you have to use the Build tool to create a new
value that doesn't exist in the table as it stands
Multiply the number of each title by its retail cost and format the
results to display as currency
Sort the results in this order:
1. Total Value
2. Book title
11. What and how many books do we have on order and how
much of a break are we getting on the price? I need to know
how much of a price break we get on each book and total
savings we are getting on each order.
Two tables, four values - two from a field, two created with a
built function
Show:
The name of each book ordered
The number of books ordered
The price break of each book - call this field Price Break
And the total of the savings per order - call this field Total
Savings
This will require
A simple select query that requires data to be pulled from
several different tables and a formula that applies to two
different tables
You may need to include some fields in the query, but not show
them in the results

Sort the results in this order:

1. Total Savings
2. Book title
12. I need to rattle some publisher cages about slow
deliveries. Get me a list of the publishers as well as their cities
and states (or countries). Sort it by publishers because I also
want to see how many of each title we have ordered from each
one and how much each order will cost if we have to buy it
locally at full retail price.
Three tables, four values - three from a field, one created with
a built function
This calls for values from all orders, whether already delivered or not.
Show:
The name of each publisher of the book ordered
The name of each book ordered
The cost of the order if it has to be purchased at the book retail
price (the number of books on an order multiplied by the retail
price of that particular title)
The state and/or country for each publisher
You will need the number of books ordered, but not in the results of the
query
Again, a query that calls for values from multiple tables, with an
expression
Dont forget to SUM the total cost, in case you have more than
one order for the same book at the same price

Sort the results in this order:


1. Total cost of the order
2. Publisher name
13. For no particular reason, of the books in our collection, I
would like to know what authors are published by what
publishers and how many titles each author has by that
publisher. Make it so I can do it by individual publisher.
Four tables, three values (of which only two will show) - two
from a field, one with a totals criteria
Include in the query design:

A non-showing parameter that will allow me to enter the


publisher I wish to query

The number of book titles associated with each author that is


published by that publisher

The name of the authors that are associated with that publisher

Sort the results in this order:


1. Number of titles shows the largest number of titles per author to
the smallest number of titles per author
2. Author name
14. OK, this is the last request. Our investments have lost
value and this has cut into our budget. We need to know where
we can save some money fast. Get a list of all our outstanding
orders, ones that we have sent to the publishers, but that the
publishers have not yet filled. We need to see how much
money we have allocated for these orders so we can cancel
them if we have to. I promise, this is the last one.
Two tables, seven values (of which only six will show) - six
from a field, one that has to be calculated
This query could be the source of a report, which would present a
formatted paper copy of the result of this query.
For each distinct order that has not been received yet, show only the
following fields:
1. The date of the order
2. The book title
3. The publisher name
4. The discount price of the book
5. The number of books ordered, and
6. The total amount of money owed to the publisher for that order.
o (Call the last field Amount Owed)
o A shipment is not paid for until it is received
NOTE: This calls for a select across multiple tables, newly built fields of
new data, application of functions, and use of the NULL criteria. This is
a request for a list of things that have not yet happened, not a list of
things that have happened already.
Sort the results in this order:
1. Amount owed (from largest to least)
2. Publisher name
3. Book title
4. Date of the order