select u.UserName,u.UserGrade,count(o.OrderId) as ordercount,count(o.price) as pricecount
from userinfo as u inner JOIN orders as o on u.UserName=o.UserName where u.UserName= 'admin' and o.state=0
group by u.UserName,u.UserGrade
from userinfo as u inner JOIN orders as o on u.UserName=o.UserName where u.UserName= 'admin' and o.state=0
group by u.UserName,u.UserGrade
http://topic.csdn.net/u/20071023/21/997c7e68-6d8f-43c1-aa3c-0bccfb9293d0.html
select col1,count(col2),max(col2),min(col2),sum(col2)from t group by col1
from userinfo as u inner JOIN orders as o on u.UserName=o.UserName where u.UserName= 'admin' and o.state=0
group by u.UserName,u.UserGrade
谢谢,揭帖了
group by u.username,u.usergrade
group by u.username,u.usergrade