0% found this document useful (0 votes)
925 views2 pages

Data Analyst SQL Task

Write a SQL query to find the cumulative net worth of the top 10 individuals for each country. The query should output the country name and total net worth. Write a SQL query to calculate the change in total daily transaction amount from the previous day based on transaction data that includes a transaction ID, date, and amount. The query should output the date and change in total amount.

Uploaded by

ShadabAkhtar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
925 views2 pages

Data Analyst SQL Task

Write a SQL query to find the cumulative net worth of the top 10 individuals for each country. The query should output the country name and total net worth. Write a SQL query to calculate the change in total daily transaction amount from the previous day based on transaction data that includes a transaction ID, date, and amount. The query should output the date and change in total amount.

Uploaded by

ShadabAkhtar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL

Problem 1:

Consider the table containing the list of individuals for every country along with their net worth.
The table structure is like:
-----------------------------------------
Country | Name | Net Worth
------------------------------------
India | Mukesh Ambani | 40000000000
US | Bill Gates | 90000000000
US | Jeff Bezos | 95000000000
…...
-----------------------------------------

Country (VARCHAR) - Name of any country


Name (VARCHAR) - Name of any individual
Net worth (DOUBLE) - Total net worth of the individual

Question:
Write a SQL query in order to find the cumulative net worth of top 10 individuals for every
country.
Expected output:

Country | Total Net worth


-------------------------
India | 100000000000
US | 200000000000
Problem 2:

Consider the table containing the transactions of a restaurant


The table structure is like:
-----------------------------------------
transaction_id | date | amount
------------------------------------
1 | 2019-07-01 | 100
2 | 2019-07-01 | 120
3 | 2019-07-01 | 110
4 | 2019-07-02 | 160
5 | 2019-07-02 | 700
6 | 2019-07-03 | 120
7 | 2019-07-03 | 130
8 | 2019-07-03 | 140
…...
-----------------------------------------

transaction_id (INT) - Unique transaction ID for every row


Date (Date) - Date of the transaction
Amount (DOUBLE) - Billed amount

Question:
Write a SQL query to find the increase in total transaction amount on a daily basis. To clarify
further, find the change (increase or decrease) in total transaction amount from the previous day

Expected output:

date | changed_by
-------------------------
2019-07-01 | 330
2019-07-02 | 530
2019-07-03 | -470

You might also like