Professional Documents
Culture Documents
SQL Assessment Bureau - Id
SQL Assessment Bureau - Id
Instructions
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
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
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