>>主要是 与现在的日期相比 得到超出 3 个月的 不知道到怎么写呀
where datediff(mm,c,getdate())>3
where datediff(mm,c,getdate())>3
解决方案 »
- 为何【用友、金蝶】的erp系统的数据库中,不设表间的关联和约束呢?
- 请教SQL用户自定义函数怎么用表做参数?(爱新觉罗.毓华 拜托看下,谢谢)
- 如何得到一个参数便能执行存储过程?
- 貼一個我寫的關於生產排程的存儲過程。還不完善,目前隻針對單個訂單,沒有考慮到訂單沖突
- sql语句如何 按指定的某列的摸个值排序
- 没分了,下次一定补分!请高手帮忙解决用程序动态建临时表问题?感谢!
- 怎么处理插入多条数据时的自动编码呀?
- 惨!仔细一试又出毛病了,“请教:关于VFP数据表的独占打开”之继篇
- ×高分求教!!!如何在SQL Server中打印所设计表的结构
- 求写一个sql语句
- 请问这个SQL语句怎么写?
- 循环计数问题 急 在线等
m.a,m.b,n.c
from
table1 m
inner join
(select b,max(c) c from table2 group by b) n
where
datediff(month,n.c,getdate()) > (case when day(n.c)>day(getdate()) then 4 else 3 end)
m.a,m.b,n.c
from
table1 m
inner join
(select b,max(c) c from table2 group by b) n
where
datediff(month,n.c,getdate()) > (case when day(n.c)>day(getdate()) then 3 else 2 end)
A.C=(Select C from table2 Where a=A.a)
from table1 a,table2 b
where a.b=b.b
and b.c<dateadd(month,-3,getdate()) --日期限制
and not exists( --去重复处理
select * from table2
where b=b.b
and b.c<dateadd(month,-3,getdate())
and c>b.c)
(select e.a,
from talbe2 e
group by e.b
having (DATEADD(month, 3, max(e.c))) < getdate() )