Conditional Count

Another SQL job interview question I came across recently. This question tests your understanding of SQL Group Functions. Given the following tables:

Orders table

This table represents the orders of a package delivery company. As you can see, each row represents one order, and has four columns:

  • OrderDate – holds the order date.
  • CustomerTypeID – holds the customer type such that 1 represents a private customer, and 2 represents a business customer.
  • ShipTypeID – holds the shipping type such that L represents a domestic shipping, and O represents an international shipping.
  • Quantity – holds the number of units which will be delivered.

Package_Orders

Customers table

This table represents the type of customers this company has. As you can see, each row represents different type of customers, and has two columns:

  • CustomerTypeID – holds the customer type number.
  • CustomerTypeDescription – holds the customer type description.

customers

Your task:

Create a query to display the total number of units sent by international and domestic shipping, for each day, and for each customer type.

 

שאלת ראיון עבודה - סכימת הזמנות

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…