Y
Y
Yaroslav Sokolovsky2021-12-05 09:57:53
Python
Yaroslav Sokolovsky, 2021-12-05 09:57:53

How to pull out a certain type of data for a period of time in sqlite?

Hello. The question is. There is a SQLITE database of the form (values ​​are all approximate)
--- serial number ---- data type --- data --- date and time --
-------------1---- ----------------5555----------------44--------"2017-5-4-15.25 .45"
--------------2--------------------5555---------- ------22--------"2017-5-4-15.25.50"-
-------------3--------- -----------5555----------------11--------"2017-5-4-15.25.55"--
-------------4--------------------4444--------------- -44--------"2017-5-4-15.26.00"--
-------------5------------- -------4444----------------22--------"2017-5-4-15.26.05"--
---- ---------6--------------------4444----------------11-- ------"2017-5-4-15.26.10"
-------------2--------------------5555--------------- -22--------"2017-5-4-15.26.20"--
-------------3------------- -------5555----------------11--------"2017-5-4-15.26.25"--
---- ---------4--------------------4444----------------44-- ------"2017-5-4-15.26.30"--
-------------5----------------- ---4444----------------22--------"2017-5-4-15.26.35"--
-------- -----6--------------------4444----------------11------ --"2017-5-4-15.26.40"--
-------------1--------------------5555 ----------------44--------"2017-5-4-15.26.45"--
------------ -2--------------------5555----------------22--------"2017 -5-4-15.26.50"--
-------------3--------------------5555---- ------------11--------"2017-5-4-15.26.55"--

How it is possible to pull out all data of a type 4444 for a certain interval of time? That is, let's say 5 such intervals are obtained in 5 hours. I want to record each interval in a separate dictionary.
If one interval, then understandable. But not when there are many.
The date and time are different each time.
I'll try to add.
As a result, I want to get (see question)
INT1 = 44,22,11(lines 4,5 and 6)
INT2 = 44,22,11(lines 10,11 and 12)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-12-05
@rozhnev

It's not very clear what you want to get. Perhaps so?

select * from t1
where type = 4444 and date between '2017-5-4-12.00.00' and '2017-5-4-17.59.59';

SQLite fiddle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question