Download as pdf or txt
Download as pdf or txt
You are on page 1of 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