[英]Query about days function in mysql
My table named as sales
. 我的桌子名为
sales
。 It contains the column like the following. 它包含如下列的列。
fld_id int(11),
fld_date date,
fld_state varchar(45),
fld_dtcode varchar(45),
fld_companyname varchar(150),
fld_unitrate int(11),
fld_count int(11),
fld_amount int(11),
I want to find out the avg of last 30 days sale. 我想了解最近30天的平均销售情况。
pls help me to find the average of sale 请帮我找到平均销售情况
try 尝试
select avg(fld_count*fld_amount) as average
from sales
where fld_date > now() - interval 30 day
You will just use AVG()
你将只使用
AVG()
SELECT AVG(fld_amount * fld_count) AvgSales30
FROM sales
WHERE fld_date > Date_Add(curdate(), interval -30 day)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.