我有一个sqlite数据库,其中包含Date列,每15分钟包含一次
Date Hourly_value quart_value
"2015-12-30 03:00:00" "944.691025" "987.196765"
"2015-12-30 03:15:00" "941.060427"
"2015-12-30 03:30:00" "967.305421"
"2015-12-30 03:45:00" "987.196765"
"2015-12-30 04:00:00" "1016.272784" "1017.077076"
我想在两个日期之间获得hourly_values,所以当我想获得" 2015-12-30 03:00:00"之间的值时和" 2015-12-30 04:00:00",我想要
Date Hourly_value quart_value
"2015-12-30 03:00:00" "944.691025" "987.196765"
"2015-12-30 04:00:00" "1016.272784" "1017.077076"
而不是每15分钟一次
Date Hourly_value quart_value
"2015-12-30 03:00:00" "944.691025" "987.196765"
"2015-12-30 03:15:00" "941.060427"
"2015-12-30 03:30:00" "967.305421"
"2015-12-30 03:45:00" "987.196765"
"2015-12-30 04:00:00" "1016.272784" "1017.077076"
在sql中我找不到一种方法来获取某个范围之间的日期,只考虑几个小时,因为使用两者之间将给出4个值(每15分钟1个值)。
SELECT * FROM Conso WHERE Date BETWEEN '2015-12-30 03:00:00' AND '2015-12-30
04:00:00'
答案 0 :(得分:1)
更通用的解决方案可能是SELECT* From Conso WHERE (Date BETWEEN '2015-12-30 03:00:00' AND '2015-12-30 ) AND (INSTR(Date,':00:00') >0)