INLS161-002 | Spring 2017

Task 5.06: Queries, Set 2


Monday November 20, 2017 Class Plan

First, a review on

  1. forms
  2. book entries
  3. book orders and the
  4. shelving report list; link to video

I will show you completed examples, so you can clear up any problems that might interfere with your more complex queries.

Second, a review on the first queries we did in class and a short demo of how to do all of the remaining booleans.

basic queries introduction

  1. qry01: list of publishers
  2. qry02: parameter example
  3. qry03: publishers with university in the name
  4. qry04: another parameter example
  5. qry05-08: boolean examples

Third, I will demo how to do totals and use the expression builder

I have a video that reviews these processes; I did this as an after-class followup last semester. You can watch it here if you want to go over the process in advance.

This will give you what you need to finish out this project. I will be in class early on Monday, November 20th if anyone needs any help before class. I am planning to be there at 2:00 p.m. If anyone needs to have office hours before this time, please contact me to set this up.

You will have a week more to work on this project over break and we will have a final database lab on Monday, November 27th. I will also have office hours at 2:00 p.m. on that Monday.

Editing Queries Progress

Several of the Query instructions on this task 5.06 and the previous task 5.05 were confusing or seemed contradictory. I have fixed all of those that seemed to be contradictory, unclear, or confusing. So, if you were stumped on some, go back and see if it makes more sense to you now.

More Complex Queries

qry09

Hey, 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 (but only two will show) - two from a field, one created from a field 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
    • 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

qry10

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

qry11

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

Two most important sort results should be in this order:

  1. Total Savings
  2. book title

Remaining fields that are to be shown should be ordered as you think would be best for the purpose of what this query is asking.

qry12

12. I need to rattle some publisher cages about slow deliveries. Get me a list of the publishers as well as their and states and 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
  • using the Totals field, don't forget to SUM the total cost, in case you have more than one order for the same book at the same price.
    (Optional: Add a separate order for the same book to see this in action.)

Two most important sort results should be in this order:

  1. total cost of the order
  2. publisher name

Remaining fields that are to be shown should be ordered as you think would be best for the purpose of what this query is asking.

qry13

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 want to query; make this so that I can enter any part of the publisher name
  • 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

qry14

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.

Three 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.
    • (Call the last field Amount Owed)
    • a shipment is not paid for until it is received

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

Remaining fields that are to be shown should be ordered as you think would be best for the purpose of what this query is asking.



last page update: Saturday Nov 18, 2017

Instructor

Lawrence Jones

Office hours by appointment.