You are on page 1of 5

+

Instructions

● Bureau.id is a data-driven organization and we use SQL to handle data daily.


● This exercise aims to test your general SQL competency and the questions are arranged in ascending order of difficulty.
● You will have 24 hours to complete the exercise. Please send your SQL statements in text via email to your Recruiter or we can have the
discussion on the same during our face to face interview.

Final remarks:
● You can use any syntax (mySQL, BigQuery, Postgres, Redshift) that you are familiar with, yet please specify the syntax that you
are using.
● There may be more than one way to solve each question. Use any approach that you are comfortable with and comment on your
assumptions where necessary within the SQL statement.
mode_of_shipment_i mode_of_shipment
Remarks d
1 Ocean FCL
2 Ocean LCL
3 Air
4 Road

• A booking_id can link to multiple


legs
• A booking_id can have
multiple invoice_currency but
the (booking_id,

2
Instructions
invoice_currency) pair is
unique within
customer_invoice_table
• A invoice_id can link to multiple
booking_id
• All the id columns are the
primary key, i.e. unique
and auto-increment, in
their respective table.

3
Questions

1. List of booking id that was shipped by Air with departure date in Jan 2021

SELECT booking_id FROM booking WHERE date_of_departure> 01-01-2021 AND date_of_departure< 31-01-2021;

Select booking_id from booking where mode_of_shipment_id = 3 and date_of_departure between ’01-01-2021’ and ’31-01-2021’;

2. List the number of bookings by each mode of shipment id with departure date in Jan 2021

SELECT COUNT(booking_id), mode_of_shipment_id FROM booking WHERE date_of_departure between ’01-01-2021’ and
’31-01-2021’ GROUP BY mode_of_shipment_id;

3. List the bookings (by booking_id) invoiced to FurniturePlus (customer id: 214598) that departed in Jan 2021

SELECT booking_id FROM customer_invoice_body WHERE customer_id= ‘214598’ and date_of_departure between ’01-01-2021’
and ’31-01-2021’;

4. List the highest valued 10 invoices (by invoice_id) invoiced in GBP that were sent in Jan 2021

SELECT invoice_id , invoice_currency FROM customer_invoice_head INNER JOIN customer_invoice_body WHERE


invoice_currency in “GBP” ORDER BY invoice_id , invoice_currency DESC;
Select invoice_id, max(invoice_currency) from customer_invoice_head as cih inner join customer_invoice_body as cib on cih.id =
4
Questions
cib.id where invoice_currency = ‘GBP’ group by invoice_id order by max(invoice_currency) desc limit 10;

5. Return the list of customer names that had more than 10 unique invoices sent in Jan 2021.
SELECT COUNT(DISTI NT invoice_id), customer_name FROM customer_invoice_head AS cih INNER JOIN customer AS
cust ON cust.id = cih.id WHERE DISTINT invoice_id > 10 AND date_of_departure BETWEEN ’01-01-2021’ AND ’31-01-
2021’;

6. Return the the list of legs and the amount invoiced to each leg in invoice currency of FurniturePlus’ (customer id: 214598)
first ever created shipment. Hint: the integer id in the booking table is unique and auto-increment.

7. Return the list of the top 10 customers, in descending order, by sales (in invoice currency) invoiced in GBP in Jan 2021. In
addition, for each of these customers, return the next customer (by sales in invoice currency) from in the same country, the
amount of sales and the difference in sales between the current and the next customer from the same country. Hint: columns
needed:
● customer_name
● total_sales
● lag_customer_name_same_country
● lag_total_sales_same_country
● difference_in_sales

You might also like