Syntax Flashcards

1
Q

What keyword do you use to filter BEFORE input rows?

A

WHERE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What keyword do you use to filter on the OUTPUT of a calculation, and does it go before or after the aggregate function?

A

HAVING

Used after the aggregate function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the five calculation operators and what do they do?

A

COUNT - counts how many records in a specified field

SUM - calculates total value

AVG - calculates mean of specified field

MIN - gives lowest value of field in a table

MAX - gives highest value of field in a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What operators can be used with the WHERE clause?

A

OR
AND
BETWEEN
IN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In a join statement, which keyword comes last: WHERE or ORDER BY?

A

ORDER BY always comes last

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does wildcard % mean and what keyword is it used with?

A

Means ‘zero or more characters’

Used with the LIKE keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s the correct way to format a date in SQL?

A

‘YYYY-MM-DD’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What keyword can be used as a filter?

A

WHERE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the SQL SELECT statement used for?

A

Read data from a database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are two ways to limit results by a specified number of fields?

A

SQL Server version:
SELECT TOP [number limit]

MySQL version:
FROM [table name] LIMIT [number limit]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why is archiving required and what is the syntax to archive ‘deleted’ records?

A

Archiving is needed if a table becomes too large as performance will be affected.

SELECT * INTO tArchive
FROM tTable
WHERE deleteFlag = 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

To update records/fields, what order does the SQL keywords go in?

A

UPDATE

SET

WHERE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the basic syntax for adding a new column?

A

ALTER TABLE [table name]

ADD [new column name] [data type]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the basic syntax for inserting subsets of fields?

A
INSERT INTO [table name]
(
  [column names]
)
Values (
 )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the basic syntax for creating a new table?

A

SELECT * INTO [new table name]

FROM [original name]

Values (
)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly