Home >Backend Development >PHP Tutorial >Find out the sales volume of each product from 12 noon to 6 pm and sort it?
How to find out the sales volume of each product from 12 noon to 6 pm and sort the codes?
How to find out the sales volume of each product from 12 noon to 6 pm and sort the codes?
<code>select goods_id , count(*) as xl from tableName where starttime>='start_time'and endtime=<'end_time' GROUP BY goods_id order by xl DESC(ASC)</code>
hit waterヽ
Supplement: If you are calculating sales, sum(sales) as sales
This is implemented based on your specific table, mainly sql statements
select sales volume from tableName where starttime>= start and endtime=< end order by sales volume DESC(ASC)
If the amount of data is relatively large, it is recommended to create indexes on the time field and sales volume field, so that the query will be faster. The query statement is the same as the previous ones, there is no general difference, so I won’t write it here
You need to post the DDL of the table so that you can write SQL.