现有一个商品订单表,
字段为: id int 自增主键
cust_id string 用户
id product_id string 商品
id order_id string 订单
id order_day string 订单
日期,MM-DD cnt int
购买产品件数 amount float
购买产品金额 要求:输出每个用户的月均消费金额
什么数据库呢,这么多id又是什么东西,大致就是根据你的用户,月份分组
SELECT cust_id,cnt,avg(amount*jiage) from Ordertable GROUP BY cust_id , cnt ;