日期:2014-05-18 浏览次数:20724 次
select tabtimedata.区站号 as 区站号,tabaddress.站名 as 站名 , DateDiff(n, max(日期时间),getdate()) as 状态 from tabtimedata join tabaddress on tabtimedata.区站号 = tabaddress.区站号 and DateDiff(n, max(日期时间),getdate())>120 group by tabtimedata.区站号,tabaddress.站名 order by DateDiff(n, max(日期时间),getdate()) desc
select tabtimedata.区站号 as 区站号,tabaddress.站名 as 站名 , DateDiff(n, max(日期时间),getdate()) as 状态 from tabtimedata join tabaddress on tabtimedata.区站号 = tabaddress.区站号 group by tabtimedata.区站号,tabaddress.站名 having DateDiff(n, max(日期时间),getdate())>120 order by DateDiff(n, max(日期时间),getdate()) desc
------解决方案--------------------
select tabtimedata.区站号 as 区站号,tabaddress.站名 as 站名 , DateDiff(n, max(日期时间),getdate()) as 状态 from tabtimedata join tabaddress on tabtimedata.区站号 = tabaddress.区站号 group by tabtimedata.区站号,tabaddress.站名 HAVING DateDiff(n, max(日期时间),getdate())>120 order by DateDiff(n, max(日期时间),getdate()) desc
------解决方案--------------------
try:
select tabtimedata.区站号 as 区站号,tabaddress.站名 as 站名 , DateDiff(n, max(日期时间),getdate()) as 状态
from tabtimedata join tabaddress on tabtimedata.区站号 = tabaddress.区站号
where DateDiff(n, max(日期时间),getdate())>120
group by tabtimedata.区站号,tabaddress.站名
order by DateDiff(n, max(日期时间),getdate()) desc
------解决方案--------------------
select
tabtimedata.区站号 --as 区站号 把这个去掉,应该就可以了
,tabaddress.站名 as 站名 ,
DateDiff(n, max(日期时间),getdate()) as 状态
from
tabtimedata
join tabaddress on
tabtimedata.区站号 = tabaddress.区站号 and DateDiff(n, max(日期时间),getdate())>120
group by
tabtimedata.区站号,tabaddress.站名
order by
DateDiff(n, max(日期时间),getdate()) desc