Module 02b - Basic SQL - Part I/II Flashcards

1
Q

SELECT statement

A

SELECT [Column]
FROM [Table]
WHERE [condition];

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

How to eliminate duplicates

A

SELECT DISTINCT

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

Which are the the characteristics of WHERE clause

A
  • Case sensitive constants
  • Is a optional clause
  • Admits conjunction with ‘AND’ and ‘OR’ operators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to sort results

A

With the clause ‘ORDER BY’

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

How to change ascending and descending order

A

Using ASC ou DESC, as following:

ORDER BY [Column] DESC, [Column] ASC

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

Which options WHERE clause has?

A

AND to add more than one condition
OR to admit one condition OR another
IN to look for a condition of a sub-conjunct
NOT IN to negate a condition of sub-conjunct
BETWEEN to establish ranges
Math symbols
LIKE that admits wildcards _ or % (SQL 92)

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

Which built-in Functions SQL has

A

COUNT - counts the amount of rows
SUM - sums the values of a column
AVG - returns the average value of a column
MIN - returns the minimum value of a column
MAX - returns the maximum value of a column

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

Is it possible to make arithmetic calculations between columns?

A

Yes. By using statements like:
SELECT [Column1] * [Column2] AS Result…
SELECT [Column1] / [Column2] AS Result…
SELECT [Column1] + [Column2] AS Result…

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

How to return String Functions on Oracle SQL

A

Using concatenation symbols and character strings between simple coma, e.g.:
SELECT [Column1] || ‘ made of ‘ || [Column2]

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

How to group results from a report?

A

Using the SQL keyword ‘GROUP BY’

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

How to state GROUP BY keyword?

A

WHERE is placed before GROUP BY

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

How restrict grouped results

A

Using HAVING operator

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

How to eliminate a ambiguity when using HAVING operator

A

By always applying WHERE clause before HAVING operator, just for sure

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