1 / 12

Computer Science & Engineering 2111

Computer Science & Engineering 2111. Lecture 12 Sorting, Summarizing and Calculating in Queries. Sorting Results in a Query. Use the Sorting line - Ascending or Descending to sort the resulting Query Table To sort multiple fields

phuoc
Download Presentation

Computer Science & Engineering 2111

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Science & Engineering 2111 Lecture 12 Sorting, Summarizing and Calculating in Queries CSE 2111 Sorting, Summarizing and Calculating in Queries

  2. Sorting Results in a Query Use the Sorting line - Ascending or Descending to sort the resulting Query Table • To sort multiple fields • The computer will apply sort precedence for sorting fields listed on a query from left to right. • Sorting can be combined with any of the filtering techniques (criteria) we have already discussed. CSE 2111 Sorting, Summarizing and Calculating in Queries

  3. Write a query to list the City and State of all clients The list should be sorted in ascending order by State and then by City. Minor Sort Major Sort CSE 2111 Sorting, Summarizing and Calculating in Queries

  4. The data table The resulting dynaset CSE 2111 Sorting, Summarizing and Calculating in Queries

  5. You have decided to give all clients a 10% break on each charge they have made. Write a query to list the ClientID, each charge amount before the discount, the discount, and the charge amount after the discount . What if we want to create a field in a query that is the result of a calculation? CSE 2111 Sorting, Summarizing and Calculating in Queries

  6. The resulting dynaset Notice new field names CSE 2111 Sorting, Summarizing and Calculating in Queries

  7. To Aggregate fields in a Query use the Group by feature Group by Sum Avg Min Max Count StDev Var First Last Expression Where • Use the Group by feature to summarize a field – calculating its average, min, max, sum etc. • Select the group(s) you wish to aggregate - Access will automatically group by the lowest detail level field. • In the desired field(s) select the function (sum, average, etc) using the pull down menu CSE 2111 Sorting, Summarizing and Calculating in Queries

  8. Query design grid's Total Row options: Group By: Define the groups you want to perform the calculations for. Aggregate Functions: Sum, Avg, Min, Max etc. Where: Specify criteria for a field, so only those records that meet this criteria will be included in the aggregates. Expression: Use if a calculated field is required in the query. Expressions will be calculated AFTER the fields are aggregated. CSE 2111 Sorting, Summarizing and Calculating in Queries

  9. Write a query that lists how many payments were made by each Client and their total payments. List the First Name, Last Name, the number of payments made, and the total dollar amount of these payments. CSE 2111 Sorting, Summarizing and Calculating in Queries

  10. The data tables (partial view) The resulting dynaset Notice new field names CSE 2111 Sorting, Summarizing and Calculating in Queries

  11. Write a query to summarize by Client, all of the charges made after 5/1/2008. Add a surcharge of 20% to these charges. List the First Name, Last Name, Original Charge and New Charge. CSE 2111 Sorting, Summarizing and Calculating in Queries

  12. The data tables Notice new field names The resulting dynaset CSE 2111 Sorting, Summarizing and Calculating in Queries

More Related