queries that select records

42 414 0
queries that select records

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Queries That Select Records (Chapter 6 – 7) Query Basics  A Microsoft Access query is a question about the information stored in Access tables.  Your query can be a simple question about data in a single table, or it can be a more complex question about information stored in several tables.  After run query, Microsoft Access returns only the information you requested. Creating Queries in Design View  The best starting point for query creation is the Design view. − Choose Create  Queries  Query Design. − Select the table that has the data you want, and then click Add  Click Close. Creating Queries in Design View − Select the fields you want to include in query. − Arrange the fields from left to right in the order to appear in the query results. − If you want to hide one or more columns, then clear the Show checkbox for those columns. Creating Queries in Design View − Choose a sort order. − Set your filtering criteria by place the expression into the Criteria box for the appropriate field. − Choose Query Tools Design  Results  Run. Save the query. Getting the top records  Use the Top Values box on the Design View toolbar to see the top records produced by the query. − Open query in Design view. − Sort table so that the records you’re most interested in are at the top. − In the Query Tools  Design − Query Setup  In return box, −  choose a different option Creating Queries by Wizard  Create a simple Query by using wizard.  The Query wizard works by asking you a series of questions. − Choose Create  Queries  Query Wizard. Creating Queries by Wizard − Choose a query type. The Query wizard includes a few common kinds of queries.  Simple Query Wizard.  Crosstab Query Wizard.  Find Duplicates Query Wizard.  Find Unmatched Query Wizard − OK. − In the Tables/Queries box, choose the table that has the data you want. Creating Queries by Wizard − Add the fields you want to see in thequery results − Click Next. Enter query name  Click Finish. Understanding the SQL View  Behind the scenes, every query is actually a text command written in a specialized language called SQL (Structured Query Language).  To take a look at the SQL command for a query, right-click the tab title, and then choose SQL view.  Example: 1 SELECT Products.ID, Products.ProductName, Products.Price 2 FROM Products 3 WHERE (((Products.Price)>50)) 4 ORDER BY Products.Price; [...]... only records where data exists on both sides of a relationship  To see records that are not matched on the other side of the join You must modify the default query join Queries and Related Tables  Can create joins between tables in these three ways: − By creating relationships between the tables when you design the database − By selecting two tables for the query that have a field in common that. .. one table or query − Build Crosstab Query by hand Crosstab Queries  Creating a Crosstab Query with the Wizard − Display the Create tab on the Ribbon − Click the Query Wizard button in the Macros & Code group on the Ribbon − The New Query dialog box opens − Select the Crosstab Query Wizard option and then click OK − Select the table or query that contains all the fields you need for your Crosstab query,... calculated field: Price: "The price is: " & [Price] Query Functions  A function is a built-in algorithm that takes some data that you supply, performs a calculation, and then returns a result  Functions is used in: − Calculated fields To add information to your query results − Filter conditions To determine what records you see in a query − Visual Basic code Using a Function  To use a function: − Enter the... parameters let you create flexible queries by enter one pieces of information  Every time you run the query, Access prompts you to supply the missing values These missing values are the query parameters  Usually, query parameters are used in filter conditions  When run the query, you fill in the value you want to use at that particular moment Query Parameters  To create a query that uses parameters: − Create... new query by choosing Create  Queries  Query Design − From the Show Table dialog box, add the tables you want to use − Choose Query Tools Design Show/Hide  Parameters The Query Parameters dialog box appears − Choose a name and data type for parameter − Click OK to close the Query Parameters dialog box Crosstab Queries  A crosstab query is a powerful summary tool that examines huge amounts of data... and uses it to calculate information like subtotals and averages  Crosstab queries use two key ingredients: grouping and summary functions − The grouping is used to organize the rows into small sets − The summary function is used to calculate a single piece of information for each group Crosstab Queries  Creating Crosstab Queries: have two ways to create a crosstab query: − The Crosstab Query Wizard...Understanding the SQL View  Every query has common ingredients (thành phần), represented by: − SELECT: list of fields appear in the query results − FROM: indicates the table (or tables) that you’re searching − WHERE: indicates the start of your filter conditions − ORDER BY: define the sorting order Queries and Related Tables  A join line connects tables in the query design The join line connects... 1,433.20 143320.00% Yes Functions  More Mathematical Functions (Page 230)  Text Functions (Page 232)  Date Functions (Page 234) Summarizing Data  Total function is used to group the records to arrive at totals and subtotals That way, you can review large quantities of information much more easily  Example: − Counting all the students in each class − Counting the number of orders placed by each customer... Data Choice in the Total box Group By Sum Avg Min Max Count First Last Description Subgroups records based on the values in this field Adds together the values in this field Averages the values in this field Retains the smallest value in this field Retains the largest value in this field Counts the number of records (no matter which field you use) Retains the first value in this field Retains the last... Next, choose a function category in the Expression Categories list − The Expression Values list will show all the functions in that category − Double click on functions name to insert it into your expression Formatting Numbers Formatting Numbers  Format(): mathematical function that transforms numbers into text  Example: SalePrice: [Price] * 0.95 − Use the Format() function to apply a currency format: . Queries That Select Records (Chapter 6 – 7) Query Basics  A Microsoft Access query is a question about the. requested. Creating Queries in Design View  The best starting point for query creation is the Design view. − Choose Create  Queries  Query Design. − Select the table that has the data you. query. Getting the top records  Use the Top Values box on the Design View toolbar to see the top records produced by the query. − Open query in Design view. − Sort table so that the records you’re

Ngày đăng: 04/05/2014, 23:03

Mục lục

  • Creating Queries in Design View

  • Creating Queries in Design View

  • Creating Queries in Design View

  • Getting the top records

  • Creating Queries by Wizard

  • Creating Queries by Wizard

  • Creating Queries by Wizard

  • Understanding the SQL View

  • Understanding the SQL View

  • Queries and Related Tables

  • Queries and Related Tables

  • Queries and Related Tables

  • Simple Math with Numeric Fields

Tài liệu cùng người dùng

Tài liệu liên quan