如何利用时间函数???
Select
t_b_c_client.client_code,
t_b_c_client.full_name,t_b_c_client.khm,
sum(convert(numeric(10,2),t_b_b_sell_detail.default_package_amount)) as sa1,
sum(convert(numeric(10,2),t_b_b_sell_detail.total_money)) as sa2,t_b_c_client.old_client
from t_b_b_sell_detail,t_b_b_sell_head,t_b_c_client,t_b_c_class_index
where
t_b_c_client.client_code not in
(select distinct client_code from t_b_b_sell_head /* 这是一个子查询 */
where contact_code='b' ) and
t_b_b_sell_detail.corp_code=t_b_b_sell_head.corp_code and
t_b_b_sell_detail.sell_no=t_b_b_sell_head.sell_no and
t_b_b_sell_head.client_code=t_b_c_client.client_code and
t_b_b_sell_head.register_corp_code=t_b_c_client.register_corp_code and
t_b_c_client.client_type_code='2' and
t_b_c_client.client_street=t_b_c_class_index.stat_index_code and
t_b_c_class_index.stat_index_type='15' and
t_b_c_client.money_type='2'
group by
t_b_c_client.client_code,t_b_c_client.full_name,t_b_c_client.khm,t_b_c_client.old_client
order by
t_b_c_client.khm
在子查询里面,我想插入一个条件,但是不知道如何写,请大家帮帮忙
想插入的条件是
时间段选择为 between 两个月前的今天 and getdate()
其中fill_date为日期字段(yyyy-mm-dd)