0% found this document useful (0 votes)
3 views

Queries In Base

The document explains how to create queries in a database management system (DBMS) using three methods: Wizard, Design View, and SQL view. It provides detailed steps for creating queries using the Wizard and Design View, including selecting fields, setting sorting orders, and applying search criteria. Additionally, it discusses editing queries and using mathematical functions to analyze numerical data within the queries.

Uploaded by

Eric Immanuel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Queries In Base

The document explains how to create queries in a database management system (DBMS) using three methods: Wizard, Design View, and SQL view. It provides detailed steps for creating queries using the Wizard and Design View, including selecting fields, setting sorting orders, and applying search criteria. Additionally, it discusses editing queries and using mathematical functions to analyze numerical data within the queries.

Uploaded by

Eric Immanuel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Queries

A query is one of the most important feature of any DBMS. Using a query, we
can retrieve and display data from one or more tables in a database. This is
done by giving specific search criteria to the DBMS so that we are able to view
the exact information that we want.

A query can be created in three ways.


■ Using a Wizard

■ In Design View

■ In SQL view

Creating a Query
A query can be created in three ways. In this chapter you will learn the first two
methods to create a query.
(i) Using a Wizard

(ii) In Design View


(iii) In SQL view

Creating a Query Using a Wizard


To create a query using a wizard, follow the following steps.
Step 1. Open the Sports Day database. In the Database Design window, click on
Queries button present in the Database Pane.

Step 2. In the Tasks Area, click on Use Wizard to Create Query… option. The
Query Wizard.
Step 3. The first step of the wizard is to select fields from the respective tables.
The corresponding fields are displayed in the Available Fields list box.
Step 4. Select Event Name field from the list box and click the right arrow (>)
button. The field name will appear in the Fields in the Query list box.
Step 5. Clicking on the Next button will display the screen to select the sorting
order. It will set the sorting order. The result of the query can be displayed in
ascending or descending order of any particular field of the table.
Step 6. The next step is to set the search conditions or the criteria on the basis
of which records will be filtered from the table. This is the step where actually
the query is set up or the criterion is given to the database.
Step 7. The last step of the Query wizard displays the entire overview of the
query. All the steps performed till now are shown in a summarised manner.
Creating a Query in Design View
Another way to create a query is using the Design view. This is a more flexible
method to create a query from either single or a multiple tables of a database.

Follow the following steps to create a query


in Design View:
Step 1. Click Queries icon on the Objects Pane in the Database Window.
Step 2. Click Create Query in Design View icon in the Tasks Pane. The Query
Design Window appears. In the middle of the window the Add Table or Query
dialog box is displayed.
Step 3. Click on the Event table to be used in the query and then click on Add
Alternatively double click on the Events table. The table will be added to the
Tables Pane present at the top of the Query Design window.

Step 4. Similarly add EventCategory table to Tables Pane of the Query Design
window.
Step 5. Click Close button in the Add Table or Query dialog box to close it. The
tables Events and EventCategory added will be displayed in the Table pane.
Step 6. Next step is to select the fields. The field name along with the table
name is displayed in the Design grid present in the lower half of the Query
Design window
Step 7. In the grid, there is a row titled Alias. It can be used to display
meaningful names in the output.
Step 8. By default, the data that is displayed as a result of the query is not
sorted. To sort the records in either ascending or descending order of a
particular field, the Sort row is given in the grid.
Step 9. Once the query is designed, click Run Query button on the toolbar or
press F5 key. The query result will be displayed in the Tables Pane area.

Step 10. Click on Save button to save the query. The Save As dialog box will be
displayed.
Step 11. By default, the Query Name as Query1 will be displayed. Type a
different name if required. Click on OK button to save the query.
The name of the query will be seen in the Objects area in the Database window.
To run the query again and see the result s of the query, double click on the
query name. The results of the query will be displayed in a separate window. To
close the Query window, click on close button on the top right corner of the
window
Editing a Query
To edit any query, click on the Query icon of the query that has to be edited.
The list of queries that have been created will be displayed in the Objects Area.
Right click on the Query Name in the Objects Area of the Database window.
Working with Numerical Data
Till now, we have been displaying data from tables in the query. But that is not
all, we can even use certain mathematical functions to find the count, sum,
minimum, maximum or average of data values.
Step 1. Add Category Name field from EventCategory table and Points field from
Events table.
Step 2. Under the Category Name field, in the Function row, click the down
arrow. A drop down list will be displayed.
Step 3. Select Group option from the drop down list. This option forms the
groups for each of the data values in the column of Category Name.

Step 4. Similarly, under the Points column, select the Average function from the
drop down list.
Step 5. Press F5 to run the query. The query result depicting average points in
all the categories will be displayed.
Step 6. Further, we can also put conditions on groups using the Criterion row.

You might also like