My issue
I want this answer to understand the problem.
My code
/* Write a query to do the following
- We need to output the following - 'lane_id', 'origin', 'destination', and compute 'profit'
- Order by decreasing 'profitability'
- 'profit' is the alias for the column which stores the values 'Revenue' - 'running_cost'
- 'running_cost' is computed as (cost_per_distance x distance)
- **Hint:** you will need to use join all the tables - 'Revenue', 'Truck' and 'Network' and apply relevant conditions
- **Hint:** This has to be computed only for the truck_type '' */
SELECT
r.lane_id,
n.origin,
n.destination,
r.revenue - (t.cost_per_distance * n.distance) AS profit
FROM
Network n
JOIN Truck t ON n.truck_id = t.truck_id
JOIN Revenue r ON n.connection_id = r.lane_id
WHERE
t.truck_type = 'Truck2'
ORDER BY
profit DESC;
Learning course: Learn Data Analytics using SQL and Python
Problem Link: Case study - Logistics Practice Problem in Data Analytics using SQL and Python - CodeChef