Which cases have multiple events in a single day? Can you provide me a SQLite SQL query.…
- User
Which cases have multiple events in a single day?
Can you provide me a SQLite SQL query. You should use the strftime function of SQLite to get the timestamp from the date.
The data is stored in a table where each row is an event having the provided attributes (so there are no separate table containing the variant). The table is called ”events_log”.
Please consider the following information: the case identifier is called "idcase", the activity is stored inside the attribute "activity", the timestamp is stored inside the attribute "timestamp”, the resource is stored inside the attribute "resource". There is not a variant column but that can be obtained as concatenation of the activities of a case. There is not a duration column but that can be obtained as difference between the timestamp of the first and the last event.
- Assistant
In a SQLite database, you can identify cases (idcase) having multiple events on a single day by grouping events by case identifier and date, and then counting the number of events within each group. Events that have the same case identifier and fall on the same date (ignoring the time component) can be grouped together using the
strftimefunction to extract the date information from thetimestamp.Here is a SQLite SQL query that lists the case identifiers (
idcase) that have more than one event occurring on any single day, along with the date and the event count:SELECT idcase, strftime('%Y-%m-%d', timestamp) as event_date, COUNT(*) as event_count FROM events_log GROUP BY idcase, event_date HAVING event_count > 1;In this query: