Chapter 3 - SQL subsection Flashcards

1
Q

What kind of statement would you use in SQL to recode a variable into categorical data?

A

CASE statement e.g.

SELECT age, CASE
WHEN age < 18 THEN ‘Under 18’
WHEN age BETWEEN 10 AND 24 THEN ‘18-24’
ELSE ‘25 +’
END AS age_group (this names the new column)
FROM agetable

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

SELECT REPLACE(Payment, ‘partially paid’, ‘not paid’) does what?

A

will replace all values with ‘partially paid’ with ‘not paid’

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

Command to use when merging two datasets and you need to preserve both datasets unaltered?

A

INTERMEDIATE APPEND

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

Column name “ID” has 4 digit numbers but as text string and needs converting to decimal. What SQL command can convert the string into decimal with a precision of 10 digits and 2 decimal places?

A

SELECT PARSE(@ID AS DECIMAL(10, 2))
AS Result

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

joins data such that ONLY records from BOTH tables appear in the result

A

INNER JOIN

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

returns results by joining rows from two or more tables

A

OUTER JOIN

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

left outer joins followed by aggregation is also known as what?

A

BLENDING

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

transposes columns into rows

A

UNPIVOT

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

Excel function - calculate how many business days exist between a start date in the past and an end date in the future

A

NETWORKDAYS()

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

Excel function - What Excel function will return a number 1 through 7 to designate the day of the week?

A

WEEKDAY([startdate])

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

A data engineer is optimizing hardcoded database queries by filtering the date before running the query results. Prescribe a method of passing data back to the command that filters the data to run different data sets from a single report.

A

PARAMETERIZATION

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

This optimizes the data by supplying a ? in the query that filters the data before running the result set.

A

PARAMETER

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

It is written for all or a group of records and not a single record

A

AGGREGATE FUNCTIONS

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

what clause in SQL limits the number of rows returned?

A

WHERE

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

What clause is added to a SQL query to limit the number of columns returned?

A

SELECT

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

What clause is added to a SQL query to sort the results?

A

SORT