select * from order a where a.c_time >"2016-07-16 00:00:00" and a.c_time <"2016-07-17 00:00:00"
再根据 两个表的关联字段显示user表的会员数据
select * from
(select * from order a where a.c_time >"2016-07-16 00:00:00" and a.c_time <"2016-07-17 00:00:00") a
left jion
user b
on
a.user_id = b.id
里上图 表 aaa, 要按月份查找,a 出现的次数,代码如下
SELECTCAST(YEAR(rq) as varchar) + '-' + CAST(MONTH(rq) as varchar) AS date,
count(*) AS '次数'
FROM aaa
where a="a"
GROUP BY
CAST(YEAR(rq) as varchar) + '-' + CAST(MONTH(rq) as varchar)
结果如下图,看看是不是你要的
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)