Session-start flag in an online store

Session-start flag in an online store

You are an analyst at the online hypermarket FreshCart. Marketing is preparing per-session conversion metrics, and step one is to label the page-view stream: where one customer visit ends and the next begins. The agreed rule: if STRICTLY more than 30 minutes passed since the same customer's previous view, a new session starts; exactly 30 minutes still belongs to the same session. A customer's very first view always opens a new session. Label every view in page_views with this flag. Return columns: - customer_id — customer identifier; - viewed_at — view time (timestamp, as stored); - is_new_session — boolean: true if this view starts a new session, false otherwise. Sort by customer_id ascending, then viewed_at ascending. ALL views are included, first ones too. Timestamps never repeat within one customer.

A ordem das linhas importa

PostgreSQLv16
Entre para enviar

O resultado da sua consulta aparecerá aqui

Focus radio
Paused · SomaFM · Fluid