in23
2015-12-31 16:07
我需要连接四张表,
select o.orderId,u.nickName,o.serveCount,(select u.nickName from user u where u.shortUrl=o.shortUrlServer) nname ,
(select ((count(*) * (total - counterFee))*0.03)) b,-- f交易奖励
(select (count(*) * (total - counterFee))) a,-- 服务费
(SELECT (total - counterFee)) c,e.evaTextContent,e.evaLevle
from user u
INNER JOIN orders o on o.shortUrlUser = u.shortUrl
left JOIN serve s ON o.serveId=s.serveId
LEFT JOIN evaluate e on e.orderId=o.orderId;
现在想取到每一个人(nname)的订单的唯一值,就是统计每一个人的serveCount,这个怎么实现循环查询
最简单的方法,就是把这个查询做为一个子查询,在外面加select nname,count(*) from ( sql ) a group by nname
MySQL开发技巧(三)
54887 学习 · 24 问题
相似问题