Mu Sigma SQL INTERVIEW QUESTION | Consecutive events count - Dataset 1

 DROP TABLE IF EXISTS [Event];


CREATE TABLE [Event] (

    session_id INT,

    event_type VARCHAR(50),

    event_time DATETIME

);


 Dataset 1: 

-- Insert expanded event data

INSERT INTO [Event] (session_id, event_type, event_time)

VALUES

(1, 'login', '2024-10-01 08:00:00'),

(1, 'view', '2024-10-01 08:05:00'),

(1, 'purchase', '2024-10-01 08:10:00'),

(2, 'login', '2024-10-01 09:00:00'),

(2, 'add_to_cart', '2024-10-01 09:05:00'),

(2, 'purchase', '2024-10-01 09:10:00'),

(3, 'login', '2024-10-01 10:00:00'),

(3, 'view', '2024-10-01 10:05:00'),

(3, 'purchase', '2024-10-01 10:10:00'),

(4, 'login', '2024-10-01 10:30:00'),

(4, 'search', '2024-10-01 10:35:00'),

(4, 'view', '2024-10-01 10:40:00'),

(4, 'add_to_cart', '2024-10-01 10:45:00'),

(4, 'purchase', '2024-10-01 10:50:00'),

(5, 'login', '2024-10-01 11:00:00'),

(5, 'search', '2024-10-01 11:05:00'),

(5, 'view', '2024-10-01 11:10:00'),

(5, 'view', '2024-10-01 11:15:00'),

(5, 'purchase', '2024-10-01 11:20:00'),

(6, 'login', '2024-10-01 11:30:00'),

(6, 'view', '2024-10-01 11:35:00'),

(6, 'add_to_cart', '2024-10-01 11:40:00'),

(6, 'purchase', '2024-10-01 11:45:00'),

(7, 'login', '2024-10-01 12:00:00'),

(7, 'search', '2024-10-01 12:05:00'),

(7, 'view', '2024-10-01 12:10:00'),

(7, 'view', '2024-10-01 12:15:00'),

(7, 'add_to_cart', '2024-10-01 12:20:00'),

(7, 'purchase', '2024-10-01 12:25:00');



Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs