skip to Main Content

A query to return aggregations by different values in columns postgresql

I have a dataset with ecommerce events: create table sample_events( event_date date, "session" varchar, "user" varchar, page_type varchar, event_type varchar, product int8); INSERT INTO sample_events (event_date,"session","user",page_type,event_type,product) values ('2022-10-01','session1user1','user1','product_page','page_view',0), ('2022-10-01','session1user2','user2','listing_page','page_view',0), ('2022-10-01','session1user2','user2','search_listing_page','page_view',0), ('2022-10-01','session1user3','user3','product_page','page_view',0), ('2022-10-01','session2user1','user1','product_page','add_to_cart',20969597), ('2022-10-02','session2user1','user1','order_page','order',0), ('2022-10-02','session2user3','user3','product_page','add_to_cart', 34856927), ('2022-10-02','session3user3','user3','product_page','add_to_cart', 19848603), ('2022-10-04','session4user3','user3','order_page','order',0); What I…

VIEW QUESTION

Postgresql – Find start date and end date for continuous status

here is my dataset processed_on|status | ------------+-------+ 2023-01-01 |Success| 2023-01-02 |Success| 2023-01-03 |Success| 2023-01-04 |Fail | 2023-01-05 |Fail | 2023-01-06 |Success| 2023-01-07 |Fail | 2023-01-08 |Success| 2023-01-09 |Success| expected output is -------------------------- start_date|end_date|status -------------------------- 2023-01-01|2023-01-03|Success 2023-01-04|2023-01-05|Fail 2023-01-06|2023-01-06|Success 2023-01-07|023-01-07|Fail 2023-01-08|2023-01-09|Success i…

VIEW QUESTION
Back To Top
Search