码迷,mamicode.com
首页 > 数据库 > 详细

sql随笔

时间:2019-03-29 17:47:32      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:stat   datetime   join   and   order   select   group   from   str   

select c1.`pid` ,count(*) as num
from `user_contact` as c1
where c1.`uid` in
(select a2.`user_id` as num from `order_orderlistrow` as a1
INNER JOIN `order_orderlist` as a2 on a1.`order_orderlist_id` = a2.`id`
INNER JOIN `user` as a3 on a2.`user_id` = a3.`id`
where a1.`goods_good_id` = ‘64‘ and a2.`state` <> ‘0‘ and a2.`updatetime` > 1551369600 and a2.`updatetime` < 1554017391
group by a2.`user_id`
)
GROUP BY c1.`pid`
ORDER BY num desc

sql随笔

标签:stat   datetime   join   and   order   select   group   from   str   

原文地址:https://www.cnblogs.com/daochong/p/10622506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!