Interview Query

Percentage of Revenue by Year

1
Have you seen this question before?

You are generating a yearly report for your company’s revenue sources.

Calculate the percentage of total revenue to date that was made during the first and last years recorded in the table. Round the percentages to two decimal places

Example:

Input:

annual_payments table

Columns Type
amount INTEGER
created_at DATETIME
status VARCHAR
user_id INTEGER
product VARCHAR
id INTEGER

Output:

Columns Type
percent_first FLOAT
percent_last FLOAT
Next question: Rejection Reason
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query