21 | | s.shipment_id, |
22 | | p.payment_status, |
23 | | CONCAT(e.employee_name, ' ', e.employee_surname) AS employee_full_name, |
24 | | CONCAT(v.make, ' ', v.model, ' (', v.registration, ')') AS vehicle_info, |
25 | | s.shipment_date, |
26 | | Count(distinct sl.customer_id) as no_of_customers, |
27 | | SUM(sl.wine_quantity) as wine_quantity_shipped, |
28 | | SUM(sl.wine_base_price * sl.wine_quantity) AS shipment_base_price, |
29 | | SUM(sl.wine_agreed_price * sl.wine_quantity) AS shipment_agreed_price, |
30 | | COALESCE(ex.shipment_expenses, 0) as shipment_expenses, |
31 | | (SUM(sl.wine_agreed_price * sl.wine_quantity) - SUM(sl.wine_base_price * sl.wine_quantity) - COALESCE(ex.shipment_expenses, 0)) as shipment_profit |
| 21 | s.shipment_id AS ShipmentId, |
| 22 | p.payment_status AS PaymentStatus, |
| 23 | CONCAT(e.employee_name, ' ', e.employee_surname) AS EmployeeFullName, |
| 24 | CONCAT(v.make, ' ', v.model, ' (', v.registration, ')') AS VehicleInfo, |
| 25 | TO_CHAR(s.shipment_date, 'DD-MM-YYYY') AS ShipmentDate, |
| 26 | COUNT(DISTINCT sl.customer_id) AS NumberOfCustomers, |
| 27 | SUM(sl.wine_quantity) AS WineQuantityShipped, |
| 28 | SUM(sl.wine_base_price * sl.wine_quantity) AS ShipmentBasePrice, |
| 29 | SUM(sl.wine_agreed_price * sl.wine_quantity) AS ShipmentAgreedPrice, |
| 30 | COALESCE(ex.shipment_expenses, 0) AS ShipmentExpenses, |
| 31 | (SUM(sl.wine_agreed_price * sl.wine_quantity) - SUM(sl.wine_base_price * sl.wine_quantity) - COALESCE(ex.shipment_expenses, 0)) AS ShipmentProfit |