Comp1630 RQ7

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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