DB2中的SQL查询问题 [英] problem with SQL query in DB2

查看:293
本文介绍了DB2中的SQL查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当前时间戳与时间戳字段之间的区别应为> = 4小时AND
<= 24小时

解决方案

你真的没有提供足够的信息来回答问题(即,你想要数据仅来自过去,仅在未来,等等),但是我们假设您想要的时间戳列(tscolumn)超过4小时和小于24小时的数据:

  select * 
from table t
其中t.tscolumn在当前时间戳之间 - 4小时
和当前时间戳 - 24小时

如果我的假设是错误的,重写这一点很容易满足您的要求。


How can i write a query in DB2 for following thing:

The difference between current timestamp and a timestamp field in dB should be >=4 hours AND <= 24 hours

解决方案

You don't really give enough information to answer the question (i.e., do you want data only from the past, only in the future, etc), but let's assume you want the data where the timestamp column ("tscolumn") is more than 4 hours old and less than 24 hours old:

select * 
from   table t
where  t.tscolumn between current timestamp - 4 hours 
                      and current timestamp - 24 hours

If my assumption is wrong it's pretty easy to rewrite this to meet your requirements.

这篇关于DB2中的SQL查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆