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

BUSLOG REVIEWER

The document provides an overview of SQL concepts, including keywords, functions, and clauses used in querying databases. It explains terms like SELECT, FROM, JOIN, and various operators, along with examples and quiz questions to reinforce understanding. Additionally, it covers aggregate functions, date and time functions, and the use of aliases in SQL statements.

Uploaded by

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

BUSLOG REVIEWER

The document provides an overview of SQL concepts, including keywords, functions, and clauses used in querying databases. It explains terms like SELECT, FROM, JOIN, and various operators, along with examples and quiz questions to reinforce understanding. Additionally, it covers aggregate functions, date and time functions, and the use of aliases in SQL statements.

Uploaded by

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

Alias -SELECT: Specifies which columns to

retrieve.
-An alternate name for a table or column.
-FROM: Identifies the table where the
AS columns exist.
-Used to assign an alternate name to a column
or table. Comparison operators
ASC -Used to perform comparisons among
-Used to sort column values in ascending expressions.
order. Expression
Clause -Any data type that returns a value.
-A segment of an SQL statement that assists in Logical operators
the selection and manipulation of data.
-Used to test for the truth of some
Concatenation condition.
-Merging values or columns together. WHERE clause
DESC -Used to filter retrieved records.
-Used to sort column values in descending Wildcard characters
order.
-Special characters used to match parts
DISTINCT of a value.
-Used to display unique values in a column.
DISTINCT ROW
-Used to exclude records based on the
entire duplicate records, not just duplicate
fields.
ORDER BY
-Used to sort retrieved records in descending
or ascending order.
Query Aggregate functions
-A question or command posed to the -Used to return a single value based on
database. calculations on values stored in a column.
Arithmetic operators
Query Design view -Used to perform mathematical
-Enables you to create queries by selecting calculations.
table and column names and specifying Date and time functions
conditions on the data you want to retrieve.
-Used to manipulate values based on
Result set the time and date.
-Records retrieved from the database. String functions
SELECT statement -Used to manipulate strings of character(s).
-Used to retrieve records from the
database.
TOP
-Used to display records that fall at the top or
bottom of a range that is specified by an
ORDER BY clause.
TOP PERCENT
-Used to display a percentage of records that
fall at the top or bottom of a range that is
specified by an ORDER BY clause.
SECOND () Used to return an integer
from 0 to 59

TIME () Used to return the current


time.

TIMESERIAL Used to return the time for


(hour, a specific hour, minute,
minute, second) and second.

WEEKDAY () Used to return the day of


the week from a date.

YEAR () Used to return the year


from a date.

Function Description

DATE () Used to return the current


date.

DATEPART Used to return a value from


(interval, a date.
date
[firstweekday] [,
first week])

DATEPART
(Cont.)

DAY () Used to return the day of


the month from a date.

FORMAT Formats a number, date,


(ColumnName, time, or string according to
DateFormat) instructions contained in a
format expression. GROUP BY clause
ColumnName stores the -Used with aggregate functions to com-
values that need bine groups of records into a single functional
formatting. record.
DateFormat represents the
format in which you want HAVING clause
to display values. -Used with the GROUP BY clause to set
HOUR () Used to return an integer conditions on groups of data calculated from
from 0 to 23 aggregate
functions.
MINUTE () Used to return an integer
from 0 to 59 The ORDER BY clause cannot be used
in a query containing an aggregate
MONTH () Used to return the month function and no GROUP BY clause.
from a date.
The GROUP BY clause must appear
NOW () Used to return the current before the ORDER BY clause.
date and time.
Cartesian product NOT
-Result produced when each row in one -Used to match any condition opposite of the
table is multiplied by the total number of rows one defined.
in another table. SOME
INNER JOIN -Used to retrieve records from the main query
-Used to instruct the DBMS to combine that match any of the records in the subquery.
matching values from two tables. Subquery
LEFT JOIN -A query linked to another query enabling
-Selects every record from the table specified values to be passed among queries.
to the left of the LEFT JOIN keywords.
Quiz 4
ON
1. What two keywords must be used in the
-Used to specify a condition. SELECT statement?
Qualification - The two keywords that must be used in a
-Used to match a column with a specific table. basic SELECT statement are SELECT and
FROM. Every SELECT statement contains the
RIGHT JOIN SELECT keyword and the FROM keyword.
-Selects every record from the table specified
to the right of the RIGHT JOIN keywords. 2. Records retrieved from the database are
Self join often referred to as what?
- Records retrieved from the database are
-Used to join a table to itself.
often referred to as a result set.
UNION
-Used to combine records from two queries 3. True or False. The TOP keyword is used to
while excluding duplicate records. display records that fall in the middle of a range
specified by an ORDER BY clause.
UNION ALL
- FALSE. TOP keyword is used to display
-Used to combine records from two queries records that fall at the top or bottom of a
while including duplicate records. range that is specified by an ORDER BY
ALL clause.
-Used to retrieve records from the main query
4. True or False. The AS keyword is used to
that match all of the records in the subquery.
create an alias.
ANY - FALSE. AS keyword is used to assign an
-Used to retrieve records from the main query alternate name to a column or table.
that match any of the records in the subquery.
5. True or False. The DISTINCT keyword is
Correlated subquery
used to display duplicate values in a column.
-Executes once for each record a referenced - FALSE. DISTINCT keyword is used to display
query returns. unique values in a column.
EXISTS
-Used to check for the existence of a value in Quiz 5
the subquery. 1. True or False. An expression is a special
character used to match parts of a value.
IN - FALSE. Wildcard characters are the special
-Used to compare values in a column against characters used to match parts of a value.
column values in another table or query. However, an expression is any data type that
Non-correlated subquery returns a value.

-Executes once since it contains no


reference to an outside query.

2. True or False. The following queries are


equivalent:
Query 1: 1. True or False. The divide (/) operator is used
SELECT * to return the remainder in division.
FROM Tools - FALSE. Divide (/) is used to perform division.
WHERE ToolID > 3 AND ToolID < 10; Because it is Modulus (%) who is used
Query 2: to return the remainder in division.
SELECT *
FROM Tools 2. True or False. Aggregate functions operate
WHERE ToolID BETWEEN 3 AND 10; on only one row at a time.
- FALSE. - FALSE. Aggregate functions is used to return
a single value based on calculations on
values stored in a column.

3. True or False. The ddd date format displays


the full names of days.
- The ddd date format displays the first three
letters of the weekday (Sun to Sat).

4. True or False. The CURRENTTIME ()


function is used to return the current time.
3. Using the Friends table in Figure 5-16, what -FALSE. TIME () is used to return the current
will the following query return? time.
SELECT FriendsID
FROM Friends
WHERE Lastname = 'Jones' AND
Email IS NULL; 5. True or False. The numeric representation of
dates is called a Julian (or serial) date.
-- TRUE. A Julian date (or serial date) is a
numeric representation of dates, typically used
in computations. Each day is assigned a
unique, consecutive number starting from a
4. True or False. The exclamation mark (!) in
specific
the following
reference date.
WHERE clause means NOT:
WHERE Location LIKE '[!A-C]';
Quiz 7
- FALSE.
1. True or False. The GROUP BY clause can
only be used in queries that contain at least
two
aggregate functions.
-FALSE. GROUP BY clause, which is used
5. True or False. The OR operator is with aggregate functions to combine groups of
processed before the AND operator in the records into a single record. The GROUP BY
order of clause can only be used in queries that
evaluation. contain at least one aggregate function.
- FALSE. The AND and OR operators are used (Otherwise, there is no need for the GROUP
to separate two conditions. The AND BY!)
operator requires that both expressions on
either side of the AND operator be true for data
to be returned. The OR operator requires at
least one expression on either side of the OR
operator to be true in order for data to be
returned.

Quiz 6
3. True or False. Table aliases are created just
2. Will the following query work? like column aliases.
SELECT DATE () AS TodaysDate -TRUE – Table aliases are created similarly to
FROM Transactions column aliases, often using the AS
GROUP BY CustomerID; keyword.
-It will not work. DATE() is typically a MySQL
function that returns the current date. This 4. True or False. The UNION ALL keyword is
query asks for a single value (DATE()) without used to combine records from two queries
any aggregation or a column to group by, while
which conflicts with the GROUP BY clause. excluding duplicate records.
GROUP BY Clause Rules: When you use -FALSE – The UNION ALL keyword includes
GROUP BY, every column in the SELECT duplicate records; it is UNION that
clause must either. Be part of the GROUP BY excludes duplicates.
clause, or Use an aggregate function (e.g.,
SUM(), COUNT()). Since DATE() is constant 5. True or False. A left outer join is used to
(returns the same value for all rows), it doesn't select every record from the table specified to
make sense to group by CustomerID because the left
no other columns are being aggregated. of the LEFT JOIN keywords.
-TRUE – A left outer join includes all records
3. True or False. When using the GROUP BY from the table on the left and the
clause with a WHERE clause, the GROUP BY matched records from the right table.
clause must appear before the WHERE clause.
- FALSE. Whenever you use the GROUP BY Quiz 9
clause with a WHERE clause, the GROUP 1. True or False. A correlated subquery
BY clause must appear after the WHERE executes once for each record a referenced
clause. query returns.
*TRUE A correlated subquery executes once
4. True or False. The GROUP BY clause must for each record returned by the outer
appear before the ORDER BY clause. query.
- FALSE. The GROUP BY clause must appear
before the ORDER BY clause. 2. True or False. The NOT operator is used to
instruct Microsoft Access to match any
5. True or False. The HAVING clause filters condition
rows before any data is grouped. opposite of the one defined.
-FALSE. The WHERE clause can be used with *TRUE The NOT operator is used to match
the HAVING clause since the WHERE clause conditions opposite to those defined.
filters rows before any data is grouped and the
HAVING clause filters rows after data is 3. True or False. The IN predicate is often used
grouped. with the following comparison operators:
*FALSE The IN predicate is typically used with
Quiz 8 lists of values, not comparison
1. True or False. A join enables you to use a operators like =, <, >, <=, >=.
single SELECT statement to query two or more
tables simultaneously. 4. True or False. A subquery linked by the IN
-TRUE A join enables querying two or more predicate can return two columns.
tables simultaneously in a single *FALSE A subquery linked by the IN predicate
SELECT statement. must return a single column.

2. True or False. The following shows the 5. True or False. Subqueries nested within
correct syntax to qualify a table and column other queries are processed first, working
name: outward.
Tablename,Columnname. *TRUE Subqueries are processed starting from
-FALSE The correct syntax for qualifying a the innermost query outward.
table and column name is
Tablename,Columnname (not a comma).

You might also like