select
date_format(qar.create_date, '%y-%m-%d') as qarcreatedate,
(case when qar.create_date > 0 then qar.id
when qar.create_date = "null" then 0 end
) as qarid
from
xx_qrcode q
left join xx_qrcode_access_record qar on qar.qrcode_id = q.id
right join xx_product p on q.product_id = p.id
where
p.stores is null
and qar.create_date between '2015-05-29' and '2015-06-05'
group by qar.create_date
SELECT a.`trday` FROM `tssyscalender` a -- 30天的日期的日历表
LEFT JOIN `secumaster` b ON a.trday=b.`tradingday` -- 只有一天的数据这张表
WHERE trday BETWEEN 20170401 AND 20170430
GROUP BY trday
#11
SELECT a.`trday`,COUNT(b.`associatecode`) FROM `tssyscalender` a -- 30天的日期
LEFT JOIN `secumaster` b ON a.trday=b.`tradingday` -- 只有一天的数据这张表
WHERE trday BETWEEN 20170401 AND 20170430
GROUP BY trday
#12
create function generateTime
(
@begin_date datetime,
@end_date datetime
)
returns @t table(date datetime)
as
begin
with maco as
(
select @begin_date AS date
union all
select date+1 from maco
where date+1 <=@end_date
)
insert into @t
select * from maco option(maxrecursion 0);
return
end
go
这是函数
select * from dbo.generateTime('2009-01-01','2009-01-10')
SELECT a.`trday` FROM `tssyscalender` a -- 30天的日期的日历表
LEFT JOIN `secumaster` b ON a.trday=b.`tradingday` -- 只有一天的数据这张表
WHERE trday BETWEEN 20170401 AND 20170430
GROUP BY trday
#11
SELECT a.`trday`,COUNT(b.`associatecode`) FROM `tssyscalender` a -- 30天的日期
LEFT JOIN `secumaster` b ON a.trday=b.`tradingday` -- 只有一天的数据这张表
WHERE trday BETWEEN 20170401 AND 20170430
GROUP BY trday
#12
create function generateTime
(
@begin_date datetime,
@end_date datetime
)
returns @t table(date datetime)
as
begin
with maco as
(
select @begin_date AS date
union all
select date+1 from maco
where date+1 <=@end_date
)
insert into @t
select * from maco option(maxrecursion 0);
return
end
go
这是函数
select * from dbo.generateTime('2009-01-01','2009-01-10')
create function generateTime
(
@begin_date datetime,
@end_date datetime
)
returns @t table(date datetime)
as
begin
with maco as
(
select @begin_date AS date
union all
select date+1 from maco
where date+1 <=@end_date
)
insert into @t
select * from maco option(maxrecursion 0);
return
end
go
这是函数
select * from dbo.generateTime('2009-01-01','2009-01-10')