You are on page 1of 2

SQL Assignment

Context: 
Orders that are placed on Swiggy, are captured in Order_fact. It has 5 columns namely:
1. Order_id – Unique IDs that are allocated to each order that is placed on the Swiggy app.
Every Order ID is unique and total number of Order ID is equal to the total number of rows
in the table
2. Date- Date on which the order was placed. Its in dd-mm-yyyy format
3. Status – This column has only two entries. ‘Completed’ or ‘Failed’ which indicates if the
order was failed or completed
4. City_id - This column captures the ID of the city in which orders are placed. Swiggy is live in
50 cities and each city is given an ID. For example - City ID for bangalore is 1
5. User_id - Every consumer transacting on Swiggy is given a unique ID. Since a person can
place order multiple times, the user ID can appear multiple times in order_fact
City name and city ID are captured in the City_fact table. It has two column City_id and city_name
User_id and device_type are captured in the user_fact table. There are only two kinds of
device_type i.e. Android and Web

Que1) Write a query to calculate the total number of completed orders at month level for year =
2021. The output should look the following :

Month Total orders

01-2021 50

02-2021 100

Que 2) Write a query to calculate the total completed orders by device_type and by city name
placed  in MAy’21
The output should look like the following:

City Name Device Type Total Orders

Bangalore Android 100

Bangalore Web 250

Mumbai Android 100


Python Assignment:

1. There’s a list which states the number of new users on the platform month on month for a 6
month period, starting from 100 as the number of new users in the first month.
new = [100,170,150,140,120,110] 
1. Introduce/Create an empty list 
2. Calculate the month on month % change in new users using a for loop
3. Append the calculated values to the original list created (in 1) and print the list.

    
2. Create a function “turnout” that takes the value of the month for which the delta is calculated
from the previous month and  returns ‘Bad Turnout’ if the month on month delta is less than 0 and
‘Good Turnout’ otherwise. 
What is the value for the 4th month delta?

You might also like