0% found this document useful (0 votes)
23 views2 pages

Comp1630 RQ7

The document discusses review questions about SQL queries including comparisons in the WHERE clause, DATEADD and DATEDIFF functions, aggregate operations, compound comparisons, the SUBSTRING function, the importance of the ORDER BY clause, values included in the BETWEEN operator, mandatory clauses in a SQL query, and importance of precedence in the WHERE clause.

Uploaded by

malinda.wu0925
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Comp1630 RQ7

The document discusses review questions about SQL queries including comparisons in the WHERE clause, DATEADD and DATEDIFF functions, aggregate operations, compound comparisons, the SUBSTRING function, the importance of the ORDER BY clause, values included in the BETWEEN operator, mandatory clauses in a SQL query, and importance of precedence in the WHERE clause.

Uploaded by

malinda.wu0925
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

COMP 1630 Lesson 6

Review Questions

1.What are the five types of comparisons that can be performed in the WHERE
clause?
Comparison, Range, Set membership, Pattern matching, Null

2.Describe what the DATEADD and DATEDIFF functions do.


DATEADD: adds days, months, or years to a date
DATEDIFF: gives the difference between two dates (by days, months, or years)

3.What are the five aggregate operations and what do they do?
- COUNT: Returns the number of rows that have non-null values
- SUM: Returns the sum of the values in a specified column
- AVG: Returns the average of the values in a specified column
- MIN: Returns the smallest value in a specified column
- MAX: Returns the largest value in a specified column

4.What is meant by a compound comparison and what operators are used to


implement them?
A compound comparison tests for 2 or more conditions in a WHERE clause using
AND / OR logical operators.

5.What does the SUBSTRING function do?


Extracts a portion of character string based on the specifications: (string_selected,
start_point, length).
6.Why should most SQL queries have an ORDER BY clause?
To ensure that the results of your query are sorted otherwise the results will not be
arranged in any particular order.

7.Within the context of SQL, what values are included when we specify
BETWEEN 10 and 20?
BETWEEN is inclusive of all the numbers that are specified so it will include 10-20.

8.What are the two mandatory clauses in an SQL query?


SELECT and FROM

9.Why is it important to specify precedence in a WHERE clause?


When using multiple AND and OR operators, if the precedence is not specified it
may produce incorrect and inconsistent results.

10. What are the four basic SQL data manipulation commands and what do
they do?
- SELECT: Retrieves and displays data from one or more database tables
- INSERT: Adds new rows of data into a table
- UPDATE: Modifies existing data in a table
- DELETE: Deletes (removes) rows of data from a table

You might also like