循環(huán)查詢問題
我需要連接四張表,?
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,-- 服務(wù)費
(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;?
現(xiàn)在想取到每一個人(nname)的訂單的唯一值,就是統(tǒng)計每一個人的serveCount,這個怎么實現(xiàn)循環(huán)查詢
2016-01-08
最簡單的方法,就是把這個查詢做為一個子查詢,在外面加select nname,count(*) from ( sql ) a group by nname