SELECT x.CreateTime ,x.GoodsName ,x.GoodsSn ,x.GoodsBref ,x.ShopPrice ,SUM(x.Num) as num,
ShopPrice*SUM(x.Num) as totalmoney
FROM (SELECT
b.GoodsName,
b.GoodsSn,
b.GoodsBref,
b.ShopPrice,
a.Num,
FROM_UNIXTIME(a.CreateTime,'%Y-%m-%d' )as CreateTime
FROM kps_ordergoods a , kps_goods b
where a.GoodsId=b.GoodsId GROUP BY a.CreateTime)x
where $condition(注意 $condition 里的条件是x.GoodsSn =""的形式 不要忘记 变量前加x. )
ShopPrice*SUM(x.Num) as totalmoney
FROM (SELECT
b.GoodsName,
b.GoodsSn,
b.GoodsBref,
b.ShopPrice,
a.Num,
FROM_UNIXTIME(a.CreateTime,'%Y-%m-%d' )as CreateTime
FROM kps_ordergoods a , kps_goods b
where a.GoodsId=b.GoodsId GROUP BY a.CreateTime)x
where $condition(注意 $condition 里的条件是x.GoodsSn =""的形式 不要忘记 变量前加x. )
GROUP BY x.CreateTime ,x.GoodsName limit 10000
select o.OrderId,o.OrderSn, FROM_UNIXTIME(o.CreateTime) as OrderTime, u.UserName, o.Consignee,
o.Mobile, o.Address, o.OrderAmount, o.ShippingFee, o.UsedMoney, o.UsedIntegral,
o.PayedAmount, o.FreeFee, pm.PayName from kps_order o
inner join kps_user u on o.UserId = u.UserId
inner join kps_payment pm on o.PayId = pm.PayId
where $condition GROUP BY o.OrderSn order by o.CreateTime limit 10000";