exam questions

Exam DP-203 All Questions

View all questions & answers for the DP-203 exam

Exam DP-203 topic 2 question 10 discussion

Actual exam question from Microsoft's DP-203
Question #: 10
Topic #: 2
[All DP-203 Questions]

DRAG DROP -
You have an Apache Spark DataFrame named temperatures. A sample of the data is shown in the following table.

You need to produce the following table by using a Spark SQL query.

How should you complete the query? To answer, drag the appropriate values to the correct targets. Each value may be used once, more than once, or not at all.
You may need to drag the split bar between panes or scroll to view content.
NOTE: Each correct selection is worth one point.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: PIVOT -
PIVOT rotates a table-valued expression by turning the unique values from one column in the expression into multiple columns in the output. And PIVOT runs aggregations where they're required on any remaining column values that are wanted in the final output.
Incorrect Answers:
UNPIVOT carries out the opposite operation to PIVOT by rotating columns of a table-valued expression into column values.

Box 2: CAST -
If you want to convert an integer value to a DECIMAL data type in SQL Server use the CAST() function.
Example:

SELECT -
CAST(12 AS DECIMAL(7,2) ) AS decimal_value;
Here is the result:
decimal_value
12.00
Reference:
https://learnsql.com/cookbook/how-to-convert-an-integer-to-a-decimal-in-sql-server/ https://docs.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and-unpivot

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
SujithaVulchi
Highly Voted 3 years ago
correct answer, pivot and cast
upvoted 46 times
...
ggggyyyyy
Highly Voted 3 years ago
correct. cast not convert
upvoted 5 times
...
Alongi
Most Recent 6 months, 3 weeks ago
Correct
upvoted 1 times
...
MarkJoh
10 months, 3 weeks ago
Pivot and Cast are correct. There is an issue with the problem though. It should be CAST(avg(temp)... and not Avg (Cast(temp)...
upvoted 1 times
jongert
9 months, 3 weeks ago
No this is not correct, if you CAST(AVG(temp)) then you will first get AVG(temp) as an int. Casting it then results in the decimal value being 0 (like 2.0, 3.0...). Therefore, we have to AVG(CAST(temp)).
upvoted 2 times
...
...
ellala
1 year ago
Answer is correct
upvoted 1 times
...
kkk5566
1 year, 1 month ago
pivot and cast
upvoted 1 times
...
Ankit_Az
1 year, 4 months ago
Correct
upvoted 1 times
...
jainparag1
2 years, 2 months ago
correct explanation
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago