1 Flashcards

1
Q

Start of every statemtn

A

SELECT

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

Reference a database table

A

FROM

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

Produce 10 rows

A

LIMIT 10

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

Number of user id (no repeat)

A

COUNT( DISTINCT user_id)

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

equal, not equal, less than/equal, great than/equal

A

= <> != <= =>

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

Condition statement specific date

A

WHERE date = ‘2022-01-25’

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

More condition statements

A

AND

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

Alternative condition statement

A

OR

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

Instead of writing OR device_id = 2 OR device_id = 3 could write

A

Device_id IN (2,3)

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

Return true if value is null

A

IS NULL

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

Return a word with second letter r

A

_r%

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

Aggregate functions

A

SUM, MAX, MIN, AVG

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

Rename column name

A

AS

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

Change type

A

CAST(price AS FLOAT)

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

Make sure returns to 1dp

A

/100.0

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

Make Revenue go from highest to lowest

A

ORDER BY revenue DESC (or ASC)

17
Q

Put all product ids together to look at number sold for each

A

GROUP BY product

18
Q

When an aggregate function use instead of where clause

A

HAVING AVG(budget) >0

19
Q

Call the database a different name

A

Replicated_datawarehouse.THG.Customer c