Home  >  Article  >  Backend Development  >  Find out the sales volume of each product from 12 noon to 6 pm and sort it?

Find out the sales volume of each product from 12 noon to 6 pm and sort it?

WBOY
WBOYOriginal
2016-08-08 09:06:451160browse

How to find out the sales volume of each product from 12 noon to 6 pm and sort the codes?

Reply content:

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn