22,209
社区成员
发帖
与我相关
我的任务
分享
select 客户号,count(1) as 交易次数
from table1 where 交易日期>=convert(varchar(8),DATEADD(DD,-10,GETDATE()),112)
group by 客户号 having count(客户号)>20
create table customer_trans
(
trans_id int primary key,
customer_id int,
tran_date datetime,
tran_amount numeric(16, 4)
)
select
distinct a.customer_id
from
customer_trans a
where
coalesce((
select
count(*)
from
customer_trans
where
customer_id=a.customer_id and
tran_date>=a.tran_date and
tran_date<dateadd(d, 10, a.tran_date)
),0)>=20
--最近十天客户交易情况
select 客户号,count(1) as 交易次数
from table where 交易日期>=dateadd(dd,-10,getdate())
group by 客户号 having count(客户号)>20
select 客户号 from [Table]
where 时间条件
group by 客户号 having count(1)>20
select
客户号,count(1) as 交易次数
from
tb
where
交易日期 between dateadd(dd,-10,getdate()) and getdate()
group by
客户号
having
count(1)>=20