Changes between Version 9 and Version 10 of UseCaseModel/ShipmentDetails


Ignore:
Timestamp:
12/28/24 21:11:08 (3 weeks ago)
Author:
153093
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UseCaseModel/ShipmentDetails

    v9 v10  
    1919{{{
    2020SELECT
    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
    3232FROM shipment s
    3333JOIN payment p ON s.payment_id = p.payment_id
     
    3535JOIN vehicle v ON s.vehicle_id = v.vehicle_id
    3636JOIN shipment_load sl ON s.shipment_id = sl.shipment_id
    37 JOIN ( SELECT shipment_id, SUM(amount) AS shipment_expenses FROM shipment_has_expense_of_expense_type GROUP BY shipment_id ) ex ON s.shipment_id = ex.shipment_id
    38 WHERE s.shipment_id = 5
     37LEFT JOIN (SELECT shipment_id, SUM(amount) AS shipment_expenses FROM shipment_has_expense_of_expense_type GROUP BY shipment_id) ex ON s.shipment_id = ex.shipment_id
     38WHERE s.shipment_id = 8
    3939GROUP BY
    4040    s.shipment_id,
     
    4545    v.model,
    4646    v.registration,
    47     s.shipment_date,
     47    s.shipment_date, 
    4848    ex.shipment_expenses;
    4949}}}