Skip to content

Wrong results in the "Customers and Products Analysis Using SQL" Solution #165

@cheifowo

Description

@cheifowo

The solution for calculating low stock (in screen 4) is wrongly sorted in ascending order.
The code:

SELECT productCode, 
       ROUND(SUM(quantityOrdered) * 1.0 / (SELECT quantityInStock
                                             FROM products p
                                            WHERE od.productCode = p.productCode), 2) AS low_stock
  FROM orderdetails od
 GROUP BY productCode
 ORDER BY low_stock
 LIMIT 10;

wrongly assumes that a higher priority for restocking is given to products with a lower "low_stock" value.
The code clearly shows that a lower value will correspond with a lower quantityordered and/or higher quantityInStock. This is clearly against the purpose stated in the project's instructions.

A simple correction can be made to the code by simply sorting by descending

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions