Chapter -11 Queries in a Database Class x It
Chapter -11 Queries in a Database Class x It
Q1. What is a query? What is the need for creating a query in a database?
A query is a way to ask a database for specific information. It retrieves the data that meets
certain conditions or criteria you set.
To filter data based on specific conditions (e.g., find all students with marks above
90).
To retrieve specific fields (e.g., show only names and contact details from a list of
customers).
To sort data (e.g., list products in order of price).
To combine data from multiple tables by linking them.
In a query, an alias is like a nickname for a field or column. You can use it to give a field a
new name that is easier to understand or more relevant. For example, if the column is named
"Student_ID," you can give it the alias "Student Number."
When creating a query, you need to choose which fields (columns) from the table(s) you
want to include in your query result. For example, if you're interested in names and marks,
you would select the "Name" and "Marks" fields.
Q5. Set the criterion:
The criterion is the condition you apply to the data. For example, if you only want to see
students with more than 90 marks, you would set the criterion as "Marks > 90."
You can set the sorting order in a query to organize the results. For example, you can choose
to sort the data by marks in ascending (lowest to highest) or descending (highest to lowest)
order.
In the query wizard, the first step is to select the table(s) from which you want to retrieve
data. For example, you could choose the "Students" table.
Q9. What is the use of the Alias row in the Design grid of the Query Design
window?
In the Query Design window, the Alias row allows you to rename a field (column)
temporarily for the purpose of the query. This can make the output easier to understand,
especially if the field names in the table are long or not user-friendly.
For example, if the field name is "Std_Marks_Obtained," you can set an alias like "Marks" to
display in the results instead.
Q10. Name any four mathematical functions that can be applied to numerical
data in a query: