组合两个时间间隔查询
我有一个名为 Call_Data 的表,数据如下所示:
Arr_Date Interval Han_Time SL_Time
2011-03-16 18:39:31.000 1830 1200 245
2011-03-16 20:06:03.000 2000 261 85
2011-03-31 00:35:42.000 0030 1900 400
2011-03-31 02:13:06.000 0200 2000 350
现在我想知道 Han_time > 的记录数1800 和 SL_Time>300
所以我编写了两个查询来执行此操作:
Select Arr_Date, Interval,
Count(*) AS Han_Time_1800
From Call_Data
where Han_Time>1800
Group by Arr_Date,Interval
Order by Arr_Date,Interval
Select Arr_Date, Interval,
Count(*) AS SL_Time_300
From Call_Data
where SL_Time>300
Group by Arr_Date,Interval
Order by Arr_Date,Interval
是否有一种方法可以在一个查询中获取这两个值?
I have a table called Call_Data and the data looks like:
Arr_Date Interval Han_Time SL_Time
2011-03-16 18:39:31.000 1830 1200 245
2011-03-16 20:06:03.000 2000 261 85
2011-03-31 00:35:42.000 0030 1900 400
2011-03-31 02:13:06.000 0200 2000 350
Now I want to know the number of records that have Han_time > 1800 and SL_Time>300
So I wrote two queries to do that:
Select Arr_Date, Interval,
Count(*) AS Han_Time_1800
From Call_Data
where Han_Time>1800
Group by Arr_Date,Interval
Order by Arr_Date,Interval
Select Arr_Date, Interval,
Count(*) AS SL_Time_300
From Call_Data
where SL_Time>300
Group by Arr_Date,Interval
Order by Arr_Date,Interval
Is There a way that I could get both the values in one query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不会有帮助吗:
Will this not help: