Skip to content
Advertisement

Analysis of the completeness of the availability of products from the ClickHouse SQL database

Documentation: https://clickhouse.tech/docs/en/

Goal: 85% of the brand’s product range should be available for purchase

  1. Calculate the number of products of each brand by availability (maxItems > 0)
  2. Make a breakdown of brands by the availability of the assortment to purchase:
  • Green: > 85%
  • Yellow: 70-84%
  • Red: 0-69%
  1. Done:

Ok.

  1. Below is an example to solve:

Each brand has an assortment, but it is not all available, but only some %. You need to calculate this percentage for each brand using the formula:

(Number of all products (id) – The number of products that are not available (maxItems = 0)) / count(id) * 100% = result %

Below is an example of the request:

Result:

What should I fix in the code to count the percentage only by brand? Thank you.

Advertisement

Answer

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement