如何利用时间函数???

LiJxin 2005-12-08 10:44:47
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)
...全文
96 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxw99 2005-12-08
  • 打赏
  • 举报
回复
UP

SQL Server-----------------------------------------------------

LiJxin 2005-12-08
  • 打赏
  • 举报
回复
to 浪子
你的不成功
不过照旧有分拿,多谢捧场
LiJxin 2005-12-08
  • 打赏
  • 举报
回复
结贴啦
LiJxin 2005-12-08
  • 打赏
  • 举报
回复
to 浪子神剑

晕..........................................................
浩方软件HFWMS 2005-12-08
  • 打赏
  • 举报
回复
如果今天是31号,两个月前没有31号呢,那有今天呀
LiJxin 2005-12-08
  • 打赏
  • 举报
回复
to 阿来
已检验正2是正确的.-2没试
LiJxin 2005-12-08
  • 打赏
  • 举报
回复
to 阿来

dateadd(mm,2,fill_date)>=getdate()

这中间的2是不是应该改成负数啊?
WangZWang 2005-12-08
  • 打赏
  • 举报
回复
select distinct client_code from t_b_b_sell_head /* 这是一个子查询 */
where contact_code='b' and
DATEADD(mm,2,fill_date)>=getdate
浩方软件HFWMS 2005-12-08
  • 打赏
  • 举报
回复
.. where between datediff(convert(datetime,fill_date,120,getdate())) and getdate()

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧