SlideShare une entreprise Scribd logo
1  sur  42
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.
  − ChooseCreate  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
 − Choosea 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.
 − ChooseCreate  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 the query
  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;
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 the primary key in one
  table to the foreign key in another table.
 By default, an Access query returns 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 has the same name
 − By modifying the default join behavior
Queries and Related Tables
Calculated Fields
 To create a calculated field, you need to supply
  two details:
            Field Name : Expression

 Example: define the PriceWithTax calculated
  field:
           PriceWithTax: [Price] * 1.10
                Field      Expressio
               Name            n
Simple Math with Numeric Fields
 Simple Math with Numeric Fields
Operator Name              Example    Result
   +    Addition              1+1              2
   –    Subtraction           1–1              0
   *    Multiplication        2*2              4
   ^    Exponentiation        2^3              8
   /    Division              5/2          2.5
       Integer division      52              2
  Mod   Modulus             5 Mod 2            1
Expressions with Text
 To join text, use the ampersand (&) operator.
 For example:
  − Create a FullName field from the FirstName
    and LastName fields:
   FullName: [FirstName] & “ “ & [LastName]
  − To “The price is” to appear before each price
    value, use this 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 function name, followed by
   parentheses.
 − Inside the parentheses, put all the information
   the function needs in order to perform its
   calculations.
 Example:
     SalePrice: Round([Price] * 0.95, 2)
The Expression Builder
 To quickly find the functions you want, Access
  provides a tool called the Expression Builder.
 To launch the Expression Builder:
 − Open a query in Design view.
 − Right-click the box where you want to insert
   your expression, and then choose Build.
 − Add or edit the expression.
 − Click OK.
The Expression Builder
 To find a function:
  − Expand the Functions item, and choose Built-
    In Functions.
  − 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:
  SalePrice: Format([Price] / 0.95, "Currency")
Formatting Numbers
   Format                   Description                     Example
             Displays a number with two decimal places,
Currency                                                 $1,433.20
             thousand separators, and the currency sign.
Fixed        Displays a number with two decimal places. 1433.20
             Displays a number with two decimal places
Standard     and the thousands separator.               1,433.20

             Displays a percent value. Displays 2 digits to
Percent                                                     143320.00%
             the right of the decimal place.
             Displays a number in scientific notation, with
Scientific   two decimal places.                            1.43E+03

             Displays No if the number is 0 and Yes if the
Yes/No       number is anything else.                      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.
 − Totaling the amount of money spent on a
   single product.
Summarizing Data
 These operations are used to summarize data:
 − Count
 − Sum
 − Average
 − Max
 − Min
Summarizing Data
 Create a totals query:
  − Create a new query by choosing Create➝
    Queries ➝ Query Design.
  − Add the tables you want to use from the Show
    Table dialog box, and then click Close.
  − Add the fields you want to use.
  − Choose Query Tools Design  Show/Hide
    Totals.
Summarizing Data
 For eachfield, choose an option from the Total
  box. This option determines whether the field is
  used in a calculation or used for grouping.
 Every field must belong to one of these
  categories:
 − It’s used in a summary calculation (like
   averaging, counting, …).
 − It’s used for grouping.
 − It’s used for filtering.
Summarizing Data
 Choice in the
                                 Description
  Total box
                 Subgroups records based on the values in this
Group By
                 field.
Sum              Adds together the values in this field.
Avg              Averages the values in this field.
Min              Retains the smallest value in this field.
Max              Retains the largest value in this field.
                 Counts the number of records (no matter
Count
                 which field you use).
First            Retains the first value in this field.
Last             Retains the last value in this field.
Summarizing Data
 Example: Calculate Total for every Order
Query Parameters
 Query   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 a 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 provides an
   automated way to create a Crosstab query.
   The wizard works only with 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, and
   then click Next.
Crosstab Queries
− Select the field(s) whose values you want to
  use as row headings  click Next.
− Select the field(s) whose values you want to
  use as column headings  click Next.
− If select a date field as the column headings,
  Choose how to group dates from the list
  Next.
− Choose the field whose values grouped by the
  row and column headings that are selected.
Crosstab Queries
− Select a grouping method from the Functions
  list.
− Choose whether to include row sums by
  selecting the check box on the same page as
  the function choices, and then click Next.
− Name the query and then click Finish to see
  the Crosstab query.
Crosstab Queries
 Creating a Crosstab query in Design view: A
  simple Crosstab query has three fields:
 − One used for row headings
 − One used for column headings.
 − The Value field, which contains the data that
    you want to appear in the cells of the table.
    Tell Access how to summarize your data in the
    Crosstab query by choosing from these
    choices: Sum, Avg, Min, Max, Count, StDev, Var,
    First, or Last.
Crosstab Queries
− Choose Create ➝ Queries ➝ Query Design.
− Add the table or query you want to use in
  crosstab query.
− Query Tools  Design Query Type 
  Crosstab.
− Choose the fields use for row labels and in the
  Crosstab row, choose the Row Heading.
− Choose the fields use for Column labels and in
  the Crosstab row, choose the Column Heading.
Crosstab Queries
− Select the field containing the values that you
  want aggregated, in the Crosstab row, choose
  the Value option.
− Set the Total row:
  Group By option for column heading and
    row heading.
  Choose summarize the data for the Value
    field column.
Crosstab Queries
 Example:

Contenu connexe

Tendances (20)

Excel solver
Excel solverExcel solver
Excel solver
 
Visual binning
Visual binningVisual binning
Visual binning
 
Ms excel
Ms excelMs excel
Ms excel
 
090225 Excel Training
090225 Excel Training090225 Excel Training
090225 Excel Training
 
Advanced Excel ppt
Advanced Excel pptAdvanced Excel ppt
Advanced Excel ppt
 
Excel Excellence (Microsoft Excel training that "sticks"): Formulas
Excel Excellence (Microsoft Excel training that "sticks"): FormulasExcel Excellence (Microsoft Excel training that "sticks"): Formulas
Excel Excellence (Microsoft Excel training that "sticks"): Formulas
 
Excel 2007- Enter Formulas
Excel 2007- Enter FormulasExcel 2007- Enter Formulas
Excel 2007- Enter Formulas
 
Microsoft excel 2010 useful formula & functions
Microsoft excel 2010   useful formula & functionsMicrosoft excel 2010   useful formula & functions
Microsoft excel 2010 useful formula & functions
 
Microsoft Excel
Microsoft ExcelMicrosoft Excel
Microsoft Excel
 
Ms excel
Ms excelMs excel
Ms excel
 
Intro to Excel Basics: Part I
Intro to Excel Basics: Part IIntro to Excel Basics: Part I
Intro to Excel Basics: Part I
 
Advances in ms excel
Advances in ms excelAdvances in ms excel
Advances in ms excel
 
Module03
Module03Module03
Module03
 
Chapter.01
Chapter.01Chapter.01
Chapter.01
 
Libre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding FunctionsLibre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding Functions
 
Ppt on ms excel
Ppt on ms excelPpt on ms excel
Ppt on ms excel
 
اىفناىنمفبانفيا
اىفناىنمفبانفيااىفناىنمفبانفيا
اىفناىنمفبانفيا
 
Ms excel
Ms excelMs excel
Ms excel
 
Excel tips and tricks you should try
Excel tips and tricks you should tryExcel tips and tricks you should try
Excel tips and tricks you should try
 
Libre office calc
Libre office calcLibre office calc
Libre office calc
 

Similaire à 003.query

Advanced Filter Concepts in MS-Excel
Advanced Filter Concepts in MS-ExcelAdvanced Filter Concepts in MS-Excel
Advanced Filter Concepts in MS-ExcelP. SUNDARI ARUN
 
Easy Pivot Tutorial June 2020
Easy Pivot Tutorial June 2020Easy Pivot Tutorial June 2020
Easy Pivot Tutorial June 2020Adhi Wikantyoso
 
MS Access Ch 2 PPT
MS Access Ch 2 PPTMS Access Ch 2 PPT
MS Access Ch 2 PPTprsmith72
 
AIA101.2.Access Queries Accelerated
AIA101.2.Access Queries AcceleratedAIA101.2.Access Queries Accelerated
AIA101.2.Access Queries AcceleratedDan D'Urso
 
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...KarenMiner
 
Management of database information system
Management of database information systemManagement of database information system
Management of database information systemKAZEMBETVOnline
 
Splunk 6.2 new features
Splunk 6.2 new featuresSplunk 6.2 new features
Splunk 6.2 new featuresCleverDATA
 
Office excel tips and tricks 201101
Office excel tips and tricks 201101Office excel tips and tricks 201101
Office excel tips and tricks 201101Vishwanath Ramdas
 
Data structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 pptData structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 pptaviban
 
11 Organizing Project Details
11 Organizing Project Details11 Organizing Project Details
11 Organizing Project DetailsSoe Naing Win
 
Advanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptxAdvanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptxCliffordBorromeo
 
Cover PageComplete and copy the following to Word for your cover p.docx
Cover PageComplete and copy the following to Word for your cover p.docxCover PageComplete and copy the following to Word for your cover p.docx
Cover PageComplete and copy the following to Word for your cover p.docxfaithxdunce63732
 
SQL200.2 Module 2
SQL200.2 Module 2SQL200.2 Module 2
SQL200.2 Module 2Dan D'Urso
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfpasqualealvarez467
 
It203 class slides-unit5
It203 class slides-unit5It203 class slides-unit5
It203 class slides-unit5Matthew Moldvan
 
BBA 2 Semester DBMS All assignment
BBA 2 Semester DBMS All assignmentBBA 2 Semester DBMS All assignment
BBA 2 Semester DBMS All assignmentRoshan Kumar
 

Similaire à 003.query (20)

Advanced Filter Concepts in MS-Excel
Advanced Filter Concepts in MS-ExcelAdvanced Filter Concepts in MS-Excel
Advanced Filter Concepts in MS-Excel
 
Ms Access
Ms AccessMs Access
Ms Access
 
Easy Pivot Tutorial June 2020
Easy Pivot Tutorial June 2020Easy Pivot Tutorial June 2020
Easy Pivot Tutorial June 2020
 
MS Access Ch 2 PPT
MS Access Ch 2 PPTMS Access Ch 2 PPT
MS Access Ch 2 PPT
 
AIA101.2.Access Queries Accelerated
AIA101.2.Access Queries AcceleratedAIA101.2.Access Queries Accelerated
AIA101.2.Access Queries Accelerated
 
Set Analyse OK.pdf
Set Analyse OK.pdfSet Analyse OK.pdf
Set Analyse OK.pdf
 
MS Access 2010 tutorial 5
MS Access 2010 tutorial 5MS Access 2010 tutorial 5
MS Access 2010 tutorial 5
 
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
 
Management of database information system
Management of database information systemManagement of database information system
Management of database information system
 
Splunk 6.2 new features
Splunk 6.2 new featuresSplunk 6.2 new features
Splunk 6.2 new features
 
Office excel tips and tricks 201101
Office excel tips and tricks 201101Office excel tips and tricks 201101
Office excel tips and tricks 201101
 
Data structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 pptData structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 ppt
 
11 Organizing Project Details
11 Organizing Project Details11 Organizing Project Details
11 Organizing Project Details
 
Advanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptxAdvanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptx
 
Cover PageComplete and copy the following to Word for your cover p.docx
Cover PageComplete and copy the following to Word for your cover p.docxCover PageComplete and copy the following to Word for your cover p.docx
Cover PageComplete and copy the following to Word for your cover p.docx
 
SQL200.2 Module 2
SQL200.2 Module 2SQL200.2 Module 2
SQL200.2 Module 2
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdf
 
It203 class slides-unit5
It203 class slides-unit5It203 class slides-unit5
It203 class slides-unit5
 
Data Transformation
Data TransformationData Transformation
Data Transformation
 
BBA 2 Semester DBMS All assignment
BBA 2 Semester DBMS All assignmentBBA 2 Semester DBMS All assignment
BBA 2 Semester DBMS All assignment
 

Plus de Học Huỳnh Bá

BÀI GIẢNG NGỮ PHÁP TIẾNG ANH NGÀNH GIA CÔNG SẢN XUẤT
BÀI GIẢNG NGỮ PHÁP TIẾNG ANH NGÀNH GIA CÔNG SẢN XUẤTBÀI GIẢNG NGỮ PHÁP TIẾNG ANH NGÀNH GIA CÔNG SẢN XUẤT
BÀI GIẢNG NGỮ PHÁP TIẾNG ANH NGÀNH GIA CÔNG SẢN XUẤTHọc Huỳnh Bá
 
Civil aviation english chinese-vietnamese vocabulary (popular language) - từ ...
Civil aviation english chinese-vietnamese vocabulary (popular language) - từ ...Civil aviation english chinese-vietnamese vocabulary (popular language) - từ ...
Civil aviation english chinese-vietnamese vocabulary (popular language) - từ ...Học Huỳnh Bá
 
Tell about a girl boy that you interested in
Tell about a girl boy that you interested inTell about a girl boy that you interested in
Tell about a girl boy that you interested inHọc Huỳnh Bá
 
Thư xin đi xe đón nhân viên shuttle transport service proposal letter (chine...
Thư xin đi xe đón nhân viên shuttle transport service proposal  letter (chine...Thư xin đi xe đón nhân viên shuttle transport service proposal  letter (chine...
Thư xin đi xe đón nhân viên shuttle transport service proposal letter (chine...Học Huỳnh Bá
 
Từ vựng chuyên ngành sản xuất giày da (tiếng trung việt) 鞋类常见词汇(汉语 - 越南语)
Từ vựng chuyên ngành sản xuất giày da (tiếng trung   việt) 鞋类常见词汇(汉语 - 越南语)Từ vựng chuyên ngành sản xuất giày da (tiếng trung   việt) 鞋类常见词汇(汉语 - 越南语)
Từ vựng chuyên ngành sản xuất giày da (tiếng trung việt) 鞋类常见词汇(汉语 - 越南语)Học Huỳnh Bá
 
Common shoe and footwear vocabulary (english chinese-vietnamese)鞋类常见词汇(英语、汉语、...
Common shoe and footwear vocabulary (english chinese-vietnamese)鞋类常见词汇(英语、汉语、...Common shoe and footwear vocabulary (english chinese-vietnamese)鞋类常见词汇(英语、汉语、...
Common shoe and footwear vocabulary (english chinese-vietnamese)鞋类常见词汇(英语、汉语、...Học Huỳnh Bá
 
Chinese email 高职高专院校英语能力测试a b级
Chinese email  高职高专院校英语能力测试a b级Chinese email  高职高专院校英语能力测试a b级
Chinese email 高职高专院校英语能力测试a b级Học Huỳnh Bá
 
English chinese business languages bec中级写作电子讲义
English   chinese business languages bec中级写作电子讲义English   chinese business languages bec中级写作电子讲义
English chinese business languages bec中级写作电子讲义Học Huỳnh Bá
 
Chinese english writing skill - 商务写作教程
Chinese english writing skill  - 商务写作教程Chinese english writing skill  - 商务写作教程
Chinese english writing skill - 商务写作教程Học Huỳnh Bá
 
Giấy báo thay đổi hộ khẩu, nhân khẩu
Giấy báo thay đổi hộ khẩu, nhân khẩuGiấy báo thay đổi hộ khẩu, nhân khẩu
Giấy báo thay đổi hộ khẩu, nhân khẩuHọc Huỳnh Bá
 
祈福英语实验学校入学申请表 Clifford school application form
祈福英语实验学校入学申请表 Clifford school application form祈福英语实验学校入学申请表 Clifford school application form
祈福英语实验学校入学申请表 Clifford school application formHọc Huỳnh Bá
 
LIST OF CHINESE & VIETNAMESE COLOR NAMES 表示颜色的英语&越南语词汇 DANH MỤC TỪ VỰNG VỀ MÀ...
LIST OF CHINESE & VIETNAMESE COLOR NAMES 表示颜色的英语&越南语词汇 DANH MỤC TỪ VỰNG VỀ MÀ...LIST OF CHINESE & VIETNAMESE COLOR NAMES 表示颜色的英语&越南语词汇 DANH MỤC TỪ VỰNG VỀ MÀ...
LIST OF CHINESE & VIETNAMESE COLOR NAMES 表示颜色的英语&越南语词汇 DANH MỤC TỪ VỰNG VỀ MÀ...Học Huỳnh Bá
 
Giáo án nghiệp vụ đàm thoại tiếng anh trong nhà trường
Giáo án nghiệp vụ đàm thoại tiếng anh trong nhà trườngGiáo án nghiệp vụ đàm thoại tiếng anh trong nhà trường
Giáo án nghiệp vụ đàm thoại tiếng anh trong nhà trườngHọc Huỳnh Bá
 
Giáo trình ms power point 2003
Giáo trình ms power point 2003Giáo trình ms power point 2003
Giáo trình ms power point 2003Học Huỳnh Bá
 
Giáo trình microsoft office excel 2003
Giáo trình microsoft office excel 2003Giáo trình microsoft office excel 2003
Giáo trình microsoft office excel 2003Học Huỳnh Bá
 
Giáo án dạy tiếng anh văn phòng
Giáo án dạy tiếng anh văn phòngGiáo án dạy tiếng anh văn phòng
Giáo án dạy tiếng anh văn phòngHọc Huỳnh Bá
 
Hợp đồng giảng dạy (mẫu)
Hợp đồng giảng dạy (mẫu)Hợp đồng giảng dạy (mẫu)
Hợp đồng giảng dạy (mẫu)Học Huỳnh Bá
 
Bảng tham chiếu quy đổi một số chứng chỉ ngoại ngữ
Bảng tham chiếu quy đổi một số chứng chỉ ngoại ngữBảng tham chiếu quy đổi một số chứng chỉ ngoại ngữ
Bảng tham chiếu quy đổi một số chứng chỉ ngoại ngữHọc Huỳnh Bá
 
Useful vocabulary for the resume and interview 英文简历及面试有用词汇 danh mục từ vựng a...
Useful vocabulary for the resume and interview 英文简历及面试有用词汇 danh mục từ vựng a...Useful vocabulary for the resume and interview 英文简历及面试有用词汇 danh mục từ vựng a...
Useful vocabulary for the resume and interview 英文简历及面试有用词汇 danh mục từ vựng a...Học Huỳnh Bá
 

Plus de Học Huỳnh Bá (20)

BÀI GIẢNG NGỮ PHÁP TIẾNG ANH NGÀNH GIA CÔNG SẢN XUẤT
BÀI GIẢNG NGỮ PHÁP TIẾNG ANH NGÀNH GIA CÔNG SẢN XUẤTBÀI GIẢNG NGỮ PHÁP TIẾNG ANH NGÀNH GIA CÔNG SẢN XUẤT
BÀI GIẢNG NGỮ PHÁP TIẾNG ANH NGÀNH GIA CÔNG SẢN XUẤT
 
Civil aviation english chinese-vietnamese vocabulary (popular language) - từ ...
Civil aviation english chinese-vietnamese vocabulary (popular language) - từ ...Civil aviation english chinese-vietnamese vocabulary (popular language) - từ ...
Civil aviation english chinese-vietnamese vocabulary (popular language) - từ ...
 
Tell about a girl boy that you interested in
Tell about a girl boy that you interested inTell about a girl boy that you interested in
Tell about a girl boy that you interested in
 
Thư xin đi xe đón nhân viên shuttle transport service proposal letter (chine...
Thư xin đi xe đón nhân viên shuttle transport service proposal  letter (chine...Thư xin đi xe đón nhân viên shuttle transport service proposal  letter (chine...
Thư xin đi xe đón nhân viên shuttle transport service proposal letter (chine...
 
Từ vựng chuyên ngành sản xuất giày da (tiếng trung việt) 鞋类常见词汇(汉语 - 越南语)
Từ vựng chuyên ngành sản xuất giày da (tiếng trung   việt) 鞋类常见词汇(汉语 - 越南语)Từ vựng chuyên ngành sản xuất giày da (tiếng trung   việt) 鞋类常见词汇(汉语 - 越南语)
Từ vựng chuyên ngành sản xuất giày da (tiếng trung việt) 鞋类常见词汇(汉语 - 越南语)
 
Common shoe and footwear vocabulary (english chinese-vietnamese)鞋类常见词汇(英语、汉语、...
Common shoe and footwear vocabulary (english chinese-vietnamese)鞋类常见词汇(英语、汉语、...Common shoe and footwear vocabulary (english chinese-vietnamese)鞋类常见词汇(英语、汉语、...
Common shoe and footwear vocabulary (english chinese-vietnamese)鞋类常见词汇(英语、汉语、...
 
Chinese email 高职高专院校英语能力测试a b级
Chinese email  高职高专院校英语能力测试a b级Chinese email  高职高专院校英语能力测试a b级
Chinese email 高职高专院校英语能力测试a b级
 
English chinese business languages bec中级写作电子讲义
English   chinese business languages bec中级写作电子讲义English   chinese business languages bec中级写作电子讲义
English chinese business languages bec中级写作电子讲义
 
Chinese english writing skill - 商务写作教程
Chinese english writing skill  - 商务写作教程Chinese english writing skill  - 商务写作教程
Chinese english writing skill - 商务写作教程
 
Giấy báo thay đổi hộ khẩu, nhân khẩu
Giấy báo thay đổi hộ khẩu, nhân khẩuGiấy báo thay đổi hộ khẩu, nhân khẩu
Giấy báo thay đổi hộ khẩu, nhân khẩu
 
祈福英语实验学校入学申请表 Clifford school application form
祈福英语实验学校入学申请表 Clifford school application form祈福英语实验学校入学申请表 Clifford school application form
祈福英语实验学校入学申请表 Clifford school application form
 
LIST OF CHINESE & VIETNAMESE COLOR NAMES 表示颜色的英语&越南语词汇 DANH MỤC TỪ VỰNG VỀ MÀ...
LIST OF CHINESE & VIETNAMESE COLOR NAMES 表示颜色的英语&越南语词汇 DANH MỤC TỪ VỰNG VỀ MÀ...LIST OF CHINESE & VIETNAMESE COLOR NAMES 表示颜色的英语&越南语词汇 DANH MỤC TỪ VỰNG VỀ MÀ...
LIST OF CHINESE & VIETNAMESE COLOR NAMES 表示颜色的英语&越南语词汇 DANH MỤC TỪ VỰNG VỀ MÀ...
 
Giáo án nghiệp vụ đàm thoại tiếng anh trong nhà trường
Giáo án nghiệp vụ đàm thoại tiếng anh trong nhà trườngGiáo án nghiệp vụ đàm thoại tiếng anh trong nhà trường
Giáo án nghiệp vụ đàm thoại tiếng anh trong nhà trường
 
Giáo trình ms power point 2003
Giáo trình ms power point 2003Giáo trình ms power point 2003
Giáo trình ms power point 2003
 
Giáo trình microsoft office excel 2003
Giáo trình microsoft office excel 2003Giáo trình microsoft office excel 2003
Giáo trình microsoft office excel 2003
 
Giáo án dạy tiếng anh văn phòng
Giáo án dạy tiếng anh văn phòngGiáo án dạy tiếng anh văn phòng
Giáo án dạy tiếng anh văn phòng
 
Hợp đồng giảng dạy (mẫu)
Hợp đồng giảng dạy (mẫu)Hợp đồng giảng dạy (mẫu)
Hợp đồng giảng dạy (mẫu)
 
Bảng tham chiếu quy đổi một số chứng chỉ ngoại ngữ
Bảng tham chiếu quy đổi một số chứng chỉ ngoại ngữBảng tham chiếu quy đổi một số chứng chỉ ngoại ngữ
Bảng tham chiếu quy đổi một số chứng chỉ ngoại ngữ
 
Useful vocabulary for the resume and interview 英文简历及面试有用词汇 danh mục từ vựng a...
Useful vocabulary for the resume and interview 英文简历及面试有用词汇 danh mục từ vựng a...Useful vocabulary for the resume and interview 英文简历及面试有用词汇 danh mục từ vựng a...
Useful vocabulary for the resume and interview 英文简历及面试有用词汇 danh mục từ vựng a...
 
Bảng chữ cái hiragana
Bảng chữ cái hiraganaBảng chữ cái hiragana
Bảng chữ cái hiragana
 

003.query

  • 1. Queries That Select Records (Chapter 6 – 7)
  • 2. 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.
  • 3. Creating Queries in Design View  The best starting point for query creation is the Design view. − ChooseCreate  Queries  Query Design. − Select the table that has the data you want, and then click Add  Click Close.
  • 4. 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.
  • 5. Creating Queries in Design View − Choosea 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.
  • 6. 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
  • 7. Creating Queries by Wizard  Create a simple Query by using wizard.  The Query wizard works by asking you a series of questions. − ChooseCreate  Queries  Query Wizard.
  • 8. 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.
  • 9. Creating Queries by Wizard − Add the fields you want to see in the query results − Click Next. Enter query name  Click Finish.
  • 10. 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;
  • 11. 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.
  • 12. Queries and Related Tables  A join line connects tables in the query design. The join line connects the primary key in one table to the foreign key in another table.  By default, an Access query returns 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.
  • 13. 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 has the same name − By modifying the default join behavior
  • 15. Calculated Fields  To create a calculated field, you need to supply two details: Field Name : Expression  Example: define the PriceWithTax calculated field: PriceWithTax: [Price] * 1.10 Field Expressio Name n
  • 16. Simple Math with Numeric Fields  Simple Math with Numeric Fields Operator Name Example Result + Addition 1+1 2 – Subtraction 1–1 0 * Multiplication 2*2 4 ^ Exponentiation 2^3 8 / Division 5/2 2.5 Integer division 52 2 Mod Modulus 5 Mod 2 1
  • 17. Expressions with Text  To join text, use the ampersand (&) operator.  For example: − Create a FullName field from the FirstName and LastName fields: FullName: [FirstName] & “ “ & [LastName] − To “The price is” to appear before each price value, use this calculated field: Price: "The price is: " & [Price]
  • 18. 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.
  • 19. Using a Function  To use a function: − Enter the function name, followed by parentheses. − Inside the parentheses, put all the information the function needs in order to perform its calculations. Example: SalePrice: Round([Price] * 0.95, 2)
  • 20. The Expression Builder  To quickly find the functions you want, Access provides a tool called the Expression Builder.  To launch the Expression Builder: − Open a query in Design view. − Right-click the box where you want to insert your expression, and then choose Build. − Add or edit the expression. − Click OK.
  • 21. The Expression Builder  To find a function: − Expand the Functions item, and choose Built- In Functions. − 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.
  • 23. Formatting Numbers  Format(): mathematical function that transforms numbers into text.  Example: SalePrice: [Price] * 0.95 − Use the Format() function to apply a currency format: SalePrice: Format([Price] / 0.95, "Currency")
  • 24. Formatting Numbers Format Description Example Displays a number with two decimal places, Currency $1,433.20 thousand separators, and the currency sign. Fixed Displays a number with two decimal places. 1433.20 Displays a number with two decimal places Standard and the thousands separator. 1,433.20 Displays a percent value. Displays 2 digits to Percent 143320.00% the right of the decimal place. Displays a number in scientific notation, with Scientific two decimal places. 1.43E+03 Displays No if the number is 0 and Yes if the Yes/No number is anything else. Yes
  • 25. Functions  More Mathematical Functions (Page 230)  Text Functions (Page 232)  Date Functions (Page 234)
  • 26. 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. − Totaling the amount of money spent on a single product.
  • 27. Summarizing Data  These operations are used to summarize data: − Count − Sum − Average − Max − Min
  • 28. Summarizing Data  Create a totals query: − Create a new query by choosing Create➝ Queries ➝ Query Design. − Add the tables you want to use from the Show Table dialog box, and then click Close. − Add the fields you want to use. − Choose Query Tools Design  Show/Hide Totals.
  • 29. Summarizing Data  For eachfield, choose an option from the Total box. This option determines whether the field is used in a calculation or used for grouping.  Every field must belong to one of these categories: − It’s used in a summary calculation (like averaging, counting, …). − It’s used for grouping. − It’s used for filtering.
  • 30. Summarizing Data Choice in the Description Total box Subgroups records based on the values in this Group By field. Sum Adds together the values in this field. Avg Averages the values in this field. Min Retains the smallest value in this field. Max Retains the largest value in this field. Counts the number of records (no matter Count which field you use). First Retains the first value in this field. Last Retains the last value in this field.
  • 31. Summarizing Data  Example: Calculate Total for every Order
  • 32. Query Parameters  Query 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.
  • 33. Query Parameters  To create a query that uses parameters: − Create a 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.
  • 34. 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.
  • 35. Crosstab Queries  Creating Crosstab Queries: have two ways to create a crosstab query: − The Crosstab Query Wizard provides an automated way to create a Crosstab query. The wizard works only with one table or query. − Build Crosstab Query by hand.
  • 36. 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, and then click Next.
  • 37. Crosstab Queries − Select the field(s) whose values you want to use as row headings  click Next. − Select the field(s) whose values you want to use as column headings  click Next. − If select a date field as the column headings, Choose how to group dates from the list Next. − Choose the field whose values grouped by the row and column headings that are selected.
  • 38. Crosstab Queries − Select a grouping method from the Functions list. − Choose whether to include row sums by selecting the check box on the same page as the function choices, and then click Next. − Name the query and then click Finish to see the Crosstab query.
  • 39. Crosstab Queries  Creating a Crosstab query in Design view: A simple Crosstab query has three fields: − One used for row headings − One used for column headings. − The Value field, which contains the data that you want to appear in the cells of the table. Tell Access how to summarize your data in the Crosstab query by choosing from these choices: Sum, Avg, Min, Max, Count, StDev, Var, First, or Last.
  • 40. Crosstab Queries − Choose Create ➝ Queries ➝ Query Design. − Add the table or query you want to use in crosstab query. − Query Tools  Design Query Type  Crosstab. − Choose the fields use for row labels and in the Crosstab row, choose the Row Heading. − Choose the fields use for Column labels and in the Crosstab row, choose the Column Heading.
  • 41. Crosstab Queries − Select the field containing the values that you want aggregated, in the Crosstab row, choose the Value option. − Set the Total row:  Group By option for column heading and row heading.  Choose summarize the data for the Value field column.