Home > Backend Development > PHP Tutorial > 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
Release: 2016-08-08 09:06:45
Original
1215 people have browsed it

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>
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template