I
I
Ivan2021-05-11 11:02:52
MySQL
Ivan, 2021-05-11 11:02:52

How to make a query in the database so that it turns out like on the screen?

There is a price distribution on the chart (see screenshot)
609a398141327468832968.png

and there are 2 tables: products and options
products : id, name, description
options : id, name, price, product_id

Question - how to implement a similar result so that the query is fast?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cicatrix, 2021-05-11
@cicatrix

Make a calculated column (price_range), where the price will be rounded to tens, say (however, the step can be selected individually). It has an index.
Then select price_range, count(id) from options group by price_range
Well, then draw the chart.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question