Sobes.tech
Junior

Logistikafirma aruande Olete logistikafirma analüütik, kes jälgib laoseadete operatsioone. Te peate koostama aruande iga laosea tõhususe kohta. Iga laosea kohta arvutage: • operatsioonide koguarv (count_operations); • laoseas töödeldud kaupade koguarv (sum_quantity); • operatsiooni keskmine töötlemisaeg (avg_processing_time), arvestades ainult neid operatsioone, millel on määratud aeg (mitte NULL), ümardatuna täisarvuks; • maksimaalne ja minimaalne kaupade arv, mis on töödeldud ühes operatsioonis (max_quantity, min_quantity); • iga tüüpi operatsioonide arv («tarne», «saadetis», «ülekanne») eraldi veergudes: supply_operations, shipment_operations, transfer_operations. Filtreerige laosead, mille koguarv on suurem kui 2 ja keskmine töötlemisaeg ei ületa 60 minutit. Sorteerige tulemus laosea ID järgi kasvavas järjekorras. Sisendi formaat Operatsioonide tabel: • operation_id (int) — operatsiooni unikaalne ID • warehouse_id (int) — laosea ID • operation_type (text) — operatsiooni tüüp: «tarne», «saadetis», «ülekanne»

sobes.tech AI

Vastus AI-lt

To prepare a warehouse efficiency report, you can use the following SQL query:

SELECT
    warehouse_id,
    COUNT(*) AS count_operations,
    SUM(quantity) AS sum_quantity,
    ROUND(AVG(CASE WHEN processing_time IS NOT NULL THEN processing_time END)) AS avg_processing_time,
    MAX(quantity) AS max_quantity,
    MIN(quantity) AS min_quantity,
    SUM(CASE WHEN operation_type = 'поставка' THEN 1 ELSE 0 END) AS supply_operations,
    SUM(CASE WHEN operation_type = 'отгрузка' THEN 1 ELSE 0 END) AS shipment_operations,
    SUM(CASE WHEN operation_type = 'перемещение' THEN 1 ELSE 0 END) AS transfer_operations
FROM operations
GROUP BY warehouse_id
HAVING COUNT(*) > 2 AND ROUND(AVG(CASE WHEN processing_time IS NOT NULL THEN processing_time END)) <= 60
ORDER BY warehouse_id ASC;

Here:

  • quantity — the number of goods in the operation;
  • processing_time — the processing time of the operation (in minutes);
  • Aggregate functions are used to count and calculate statistics;
  • Filtering by the number of operations and average processing time;
  • The result is sorted by warehouse ID.