Flipkart user activity

 DROP TABLE IF EXISTS UserActivity ;


CREATE TABLE UserActivity (

    id INT,

    activity_time DATETIME,

    type VARCHAR(20)

);


INSERT INTO UserActivity (id, activity_time, type) VALUES

-- Day 1

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

(1, '2024-10-01 08:15:30', 'scroll'),

(1, '2024-10-01 08:30:00', 'log out'),

(1, '2024-10-01 12:00:00', 'log in'),

(1, '2024-10-01 12:10:30', 'scroll'),

(1, '2024-10-01 12:30:00', 'log out'),

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

(2, '2024-10-01 09:15:45', 'scroll'),

(2, '2024-10-01 09:45:00', 'log out'),

(2, '2024-10-01 14:30:00', 'log in'),

(2, '2024-10-01 14:50:00', 'scroll'),

(2, '2024-10-01 15:30:00', 'log out'),

(3, '2024-10-01 07:45:00', 'log in'),

(3, '2024-10-01 08:00:00', 'scroll'),

(3, '2024-10-01 08:30:00', 'log out'),

(3, '2024-10-01 11:15:00', 'log in'),

(3, '2024-10-01 11:25:00', 'scroll'),

(3, '2024-10-01 12:00:00', 'log out'),


-- Day 2

(1, '2024-10-02 09:00:00', 'log in'),

(1, '2024-10-02 09:20:00', 'scroll'),

(1, '2024-10-02 09:40:00', 'log out'),

(1, '2024-10-02 14:00:00', 'log in'),

(1, '2024-10-02 14:15:00', 'scroll'),

(1, '2024-10-02 14:45:00', 'log out'),

(2, '2024-10-02 08:30:00', 'log in'),

(2, '2024-10-02 08:50:00', 'scroll'),

(2, '2024-10-02 09:15:00', 'log out'),

(2, '2024-10-02 12:45:00', 'log in'),

(2, '2024-10-02 13:10:00', 'scroll'),

(2, '2024-10-02 14:30:00', 'log out'),

(3, '2024-10-02 07:30:00', 'log in'),

(3, '2024-10-02 07:50:00', 'scroll'),

(3, '2024-10-02 08:20:00', 'log out'),

(3, '2024-10-02 10:00:00', 'log in'),

(3, '2024-10-02 10:15:00', 'scroll'),

(3, '2024-10-02 10:45:00', 'log out');



SELECT * FROM UserActivity

ORDER BY 1,2

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