0% found this document useful (0 votes)
5 views10 pages

Task 7

The document outlines various SQL report queries that Ninja Van can use to extract and analyze data from its database system for strategic decision-making. It includes queries for tracking shipping statuses, calculating total costs for customers, and identifying item categories, among others. Each query is designed to improve operational efficiency and enhance customer communication by providing relevant information about shipments and deliveries.

Uploaded by

kellothermes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views10 pages

Task 7

The document outlines various SQL report queries that Ninja Van can use to extract and analyze data from its database system for strategic decision-making. It includes queries for tracking shipping statuses, calculating total costs for customers, and identifying item categories, among others. Each query is designed to improve operational efficiency and enhance customer communication by providing relevant information about shipments and deliveries.

Uploaded by

kellothermes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Task 7

SQL Reports
Introduction
Report queries are similar to the normal SQL queries expect they are used to generate reports
that the organization can use to make strategic business decisions as well as to highlight the
inefficiency in the operation. The SQL language includes several built-in functions that allow to
generate queries that summarize data in the database and could be used in the query
statement. The following are the report queries that Ninja Van could use to extract report data
from its database system.

1. Total shipping and delivery items


This query can help the company to find information or keep track of all the delivery items’
status. It outputs the results of all delivery items that have been registered in the company
system along with their status. The query includes two SELECT statements which query the
total count of items which are grouped by their statuses using the GROUP BY statement. The
results from these SELECT statements are then joined with UNION statement to display them
as a single output result.

Output

The result displays the quantity of all the items that have been registered in the Ninja Van
database system along with their tracking status.
2. Shipped Items with ‘Pending’ delivery status.
This query extracts the information about the customers whose items have been shipped to the
destination branch but is not delivered and pending for some other reasons. This will help the
company to contact those customers and inform them why their packages have not been
delivered to the destination. This will improve transparency and a sense of trust between the
company and the customers. The query joins Batches, Delivery and Customers to extract
information necessary for the reports. The joined table will be filtered where the shipping status
is “Shipped”, and the delivery status is “Pending”. This generates a result table where all the
records are the information related to the items that have been shipped but still pending to
deliver.

Output

The result includes the phone number of both sender and receiver to make the company to
contact them. It also includes the shipping date of the item.

3. Individual customer total cost


This query summarizes the total cost that individual customers have to pay to the company.
This will help the company to keep track of all the revenue generated. The query utilizes the
SUM function in SQL to calculate the total cost of all the records in the table. To calculate the
exact cost for each customer, the records in the Shipping table are grouped based on the
customer’s ID. This is done by using the GROUP BY statement on the customer’s ID column.
Additionally, the resulting value is concatenated with currency units such as “$” to enhance the
readability and understanding of the report.

Output

The result of the query outputs all the customers that have used the company’s services along
with total cost. The company can use this information to provide discounts to the customers who
have used the service multiple times.

4. Total shipping and delivery items count.


This query enables the company to identify which item categories are being transported with the
company’s services. The query joins the Items and the ItemCategories table. To get the total
number of items that belong to a specific category, the GROUP BY statement is used on the
Category column of the ItemCategories table. The output results are then order by the total
count of items that have the highest value.
Output

All the available item categories are displayed in the output along with the total count of items
under each category.

5. Shipping details information


The query describes the details information of individual shipment details which include the
customer information, item categories and item information. The query joins four different tables
including items, shipping, customers, and the item categories.

Output
6. Total item for each shipping
This query is used to extract total items that are being shipped from each location. The query
joins the Items table with the Batches to extract information about the delivery item source and
destination.

Output
7. Information of customers who have multiple services and their total cost.
The query outputs the information of the customer who has sent multiple items and their total
cost. It includes a nested SELECT statement which queries the total cost of shipping for each
customer. Once all the values from the inner SELECT statement have been evaluated, the outer
SELECT statement concatenates the currency format and puts the values that are not in the
GROUP BY statement into the aggregate functions.

Output

The result includes the customer’s name, the number of shipments that the customer has done
and the total cost for all those shipments.

8. Total and average revenue from each shipment


The output of this query includes the total cost and average cost for each shipment. The query
uses JOIN statements to connect the Shippings table and Item table. The records belong to
specific shipping record are grouped. The grouped columns are then put into the aggregate
functions to calculate the total and average cost that each shipment has. The values are
concatenated with the currency format.
Output

9. Employee and delivery route that carry heaviest items.


The given query outputs the information of the employees who are assigned to deliver the
heaviest items. The query also includes the source and destination branch that the item has to
be delivered. The structure of query includes JOIN statements for join all the necessary tables.
The data are grouped with the staffID, first name, and lastname. The remaining data is ordered
based on the total weight of the item.
Output

10. Information of customer whose shipment is still in pending state.


This query informs the company about the items that have been shipped and are still in the
pending state. The output includes all the necessary information such as the sender, receiver,
name, and the category of the product. The company can use this report information to inform
those users about the status of the items and notify them if there are any challenges with the
shipping processes. The query includes information from the customers, items, item categories
and shipping tables. The results are then filtered with the WHERE clause and the filtered result
are then ordered according to the shipping date.
Output

The above output shows all the columns that are included when using the query. It includes
both the sender and receiver information along with the name and category of the shipping item.

You might also like