Download presentation
Presentation is loading. Please wait.
1
Access SQL Feature Using SQL
2
Objectives Change the font or font size
Include fields and criteria in SQL queries Use computed fields and built-in functions in SQL queries Sort the results in SQL queries
3
Objectives Use multiple functions in the same command
Group the results in SQL queries Join tables in SQL queries Compare with Access-generated SQL
4
Opening a Database Click the Start button on the Windows taskbar, point to All Programs on the Start menu, point to Microsoft Office on the All Programs submenu, and then click Microsoft Office Access 2003 on the Microsoft Office submenu If the Access window is not maximized, double-click its title bar to maximize it If the Language bar appears, right-click it and then click Close the Language bar on the shortcut menu
5
Opening a Database Click Open on the Database toolbar, and then click Local Disk (C:) in the Look in box. Double-click the Data folder, and then make sure the Ashton James College database is selected Click the Open button If the Security Warning dialog box appears, click the Open button When the Switchboard appears, close the Switchboard by clicking its Close button
6
Changing the Font Size Click Tools on the menu bar, and then click Options on the Tools menu Click the Tables/Queries tab Click the Size box arrow, and then click 10 in the list that appears Click the OK button
7
Changing the Font Size
8
Creating a New SQL Query
If necessary, click the Queries object and then click the New button on the Database window toolbar Be sure Design View is selected and then click the OK button When the Show Table dialog box appears, click its Close button Be sure the Query1 : Select Query window is maximized Click the View button arrow and select SQL View
9
Creating a New SQL Query
10
Including Only Certain Fields
Type SELECT [Client Number],[Name],[Amount Paid],[Current Due] as the first line of the command, and then press the ENTER key Type FROM [Client]; as the second line Click the Run button
11
Including Only Certain Fields
12
Preparing to Enter a New SQL Query
Click the View button arrow Click SQL View
13
Including All Fields Delete the current command, type SELECT * as the first line of the command, and then press the ENTER key Type FROM [Client]; as the second line Click the Run button
14
Including All Fields
15
Using a Criterion Involving a Numeric Field
Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Client Number],[Name] as the first line of the command, and then press the ENTER key Type FROM [Client] as the second line, and then press the ENTER key Type WHERE [Current Due]=0; as the third line Click the Run button
16
Using a Criterion Involving a Numeric Field
17
Using a Criterion Involving a Text Field
Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Client Number],[Name] as the first line of the command, and then press the ENTER key Type FROM [Client] as the second line, and then press the ENTER key Type WHERE [City]='Lake Hammond'; as the third line Click the Run button
18
Using a Criterion Involving a Text Field
19
Using a Compound Criterion
Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Client Number],[Name] as the first line of the command, and then press the ENTER key Type FROM [Client] as the second line, and then press the ENTER key Type WHERE [City]='Lake Hammond' as the third line, and then press the ENTER key Type AND [Current Due]=0; as the fourth line and then click the Run button
20
Using a Compound Criterion
21
Using NOT in a Criterion
Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Client Number],[Name] as the first line of the command, and then press the ENTER key Type FROM [Client] as the second line, and then press the ENTER key Type WHERE NOT [City]='Lake Hammond'; as the third line Click the Run button
22
Using NOT in a Criterion
23
Using a Computed Field Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Client Number],[Name],[Amount Paid]+[Current Due] AS [Total Amount] as the first line of the command, and then press the ENTER key Type FROM [Client] as the second line, and then press the ENTER key Type WHERE [Current Due]>0; as the third line Click the Run button
24
Using a Computed Field
25
Sorting the Results Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Client Number],[Name],[Amount Paid],[Current Due],[Trainer Number] as the first line of the command, and then press the ENTER key Type FROM [Client] as the second line, and then press the ENTER key Type ORDER BY [Trainer Number],[Amount Paid]; as the third line Click the Run button
26
Sorting the Results
27
Using a Built-In Function
Click the View button arrow, click SQL View, and then delete the current command Type SELECT COUNT(*) as the first line of the command, and then press the ENTER key Type FROM [Client] as the second line, and then press the ENTER key Type WHERE [Trainer Number]='42'; as the third line Click the Run button
28
Using a Built-In Function
29
Using Multiple Functions in the Same Command
Click the View button arrow, click SQL View, and then delete the current command Type SELECT COUNT(*),SUM([Amount Paid]) as the first line of the command, and then press the ENTER key Type FROM [Client]; as the second line Click the Run button
30
Using Multiple Functions in the Same Command
31
Using Grouping Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Trainer Number],SUM([Amount Paid]) AS [Total Paid],SUM([Current Due]) AS [Total Due] as the first line of the command, and then press the ENTER key Type FROM [Client] as the second line, and then press the ENTER key Type GROUP BY [Trainer Number] as the third line, and then press the ENTER key Type ORDER BY [Trainer Number]; as the fourth line and click the Run button
32
Using Grouping
33
Restricting the Groups that Appear
Click the View button arrow and then click SQL View Click the beginning of the fourth line (ORDER BY [Trainer Number];), and then press the ENTER key Click the beginning of the new blank line, and then type HAVING SUM([Current Due])>3000 as the new fourth line Click the Run button
34
Restricting the Groups that Appear
35
Joining Tables Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Client Number],[Name],[Client].[Trainer Number],[First Name],[Last Name] as the first line of the command, and then press the ENTER key Type FROM [Client],[Trainer] as the second line, and then press the ENTER key Type WHERE [Client].[Trainer Number]=[Trainer].[Trainer Number]; as the third line Click the Run button
36
Joining Tables
37
Restricting the Records in a Join
Click the View button arrow, and then click SQL View If necessary, click immediately after the semicolon on the third line Press the BACKSPACE key to delete the semicolon, and then press the ENTER key Type AND [Current Due] > 0; as the fourth line Click the Run button
38
Restricting the Records in a Join
39
Joining Multiple Tables
Click the View button arrow, click SQL View, and then delete the current command Type SELECT [Course Offerings].[Client Number], [Name],[Course Offerings].[Course Number],[Course Description], as the first line of the command, and then press the ENTER key Type [Total Hours],[Hours Spent] as the second line of the command, and then press the ENTER key Type FROM [Course Offerings],[Course],[Client] as the third line, and then press the ENTER key
40
Joining Multiple Tables
Type WHERE [Course].[Course Number]=[Course Offerings].[Course Number] as the fourth line, and then press the ENTER key Type AND [Client].[Client Number]=[Course Offerings].[Client Number]; as the fifth line Click the Run button. Resize each column to best fit the data by double-clicking the right edge of its field selector
41
Joining Multiple Tables
42
Closing the Query and Restoring the Font Size
Click the Close Window button for the Microsoft Access - [Query1 : Select Query] window Click Tools on the menu bar, and then click Options on the Tools Menu. Click the Tables/Queries tab Click the Size box arrow, and then click 8 in the list that appears. Click the OK button
43
Closing a Database and Quitting Access
Click the Close Window button for the Ashton James College : Database window Click the Close button for the Microsoft Access window
44
Summary Change the font or font size
Include fields and criteria in SQL queries Use computed fields and built-in functions in SQL queries Sort the results in SQL queries
45
Summary Use multiple functions in the same command
Group the results in SQL queries Join tables in SQL queries Compare with Access-generated SQL
46
Access SQL Feature Complete
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.