简体   繁体   English

mssql查询发布日期范围

[英]mssql query issue date range

while running the following query in mssql 2k12, 在mssql 2k12中运行以下查询时,

select PROBSUMMARYM1.AFFECTED_ITEM,
sum(case when SLORESPONSEM1.BREACHED='t' then 1 else 0 end) BREACHED,
sum(case when SLORESPONSEM1.BREACHED='f' then 1 else 0 end) NOBREACHED,
SLORESPONSEM1.SLO_ID 
from PROBSUMMARYM1 
INNER JOIN SLORESPONSEM1 
ON NUMBER=FOREIGN_KEY 
where OPEN_TIME>'2014-11-12'
group by AFFECTED_ITEM,SLO_ID;

I get the desired output, however when I change the date in line 8 above to any one of following, I am only getting headers & no data, can anyone suggest what could be the issue, the db is having good amount of data for the mentioned date ranges, that is for sure and evident from some ready(boxed) reports from the application using same mssql instance 我得到了所需的输出,但是,当我将上面第8行中的日期更改为以下任意一项时,我仅获得标头且没有数据,任何人都可以提出可能的问题,db的数据量很大。提到的日期范围,从使用相同mssql实例的应用程序的一些就绪(带盒装)报告中可以肯定并明显地看到

where OPEN_TIME<'2016-05-31'

or 要么

where OPEN_TIME<'2016-01-01'

or 要么

where OPEN_TIME between '2016-01-01' AND '2016-06-30'

Thanks and Regards Hemant Vaswani 谢谢和问候Hemant Vaswani

Hope this helps, 希望这可以帮助,

select PROBSUMMARYM1.AFFECTED_ITEM,
sum(case when SLORESPONSEM1.BREACHED='t' then 1 else 0 end) BREACHED,
sum(case when SLORESPONSEM1.BREACHED='f' then 1 else 0 end) NOBREACHED,
SLORESPONSEM1.SLO_ID 
from PROBSUMMARYM1 
INNER JOIN SLORESPONSEM1 
ON NUMBER=FOREIGN_KEY 
where convert(date,OPEN_TIME) between '2014-11-12' And '2016-06-30'
group by AFFECTED_ITEM,SLO_ID;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM