starlets
⽇期范围内商品销售额排⾏榜的SQL语句编写
caption
⼀:涉及订单表,订单详细表
SQL:
SELECT productName '商品名称',SUM(price*number) '销售总额'
FROM t_orderdetailpyt
WHERE orderID IN (SELECT id
FROM t_order
WHERE DATE(createdate)
全国职称英语考试BETWEEN '2014-01-01'
AND '2014-01-31')
GROUP BY productID
ORDER BY SUM(price*number) DESC
LIMIT 0,10
查询结果:
⼆:涉及订单表,订单详细表,商品表
功能:从商品表中获取商品相关信息, 从详细表中获取商品销售总额, 时间范围由订单表中的⽇期限制;按商品分组,按商品销售额降序排列,查询前⼗名。
日本语SQL:
SELECT p.`name` 名称,p.`introduce` 简介,SUM(o.price*o.number) 总额
FROM t_product p
neeatoefl
JOIN t_orderdetail o
ON p.`id` = o.`productID`
derID IN (SELECT t_order.id
FROM t_order
WHERE DATE(atedate)even是什么意思
ttlement
牙医的英文BETWEEN '2014-01-01' AND '2014-01-31')
nanchang
GROUP BY o.productID
ORDER BY SUM(o.price*o.number) DESC
LIMIT 0,10
查询结果:
三:表
T_product:
T_order:
T_orderdetail:
四:页⾯显⽰排⾏