question

just4sql avatar image
just4sql asked

Sql query - count of new customers each day

I have a dataset that looks like this

listener_id

product_type

feature_code

day

123

subscription

pandora_plus

1/1/2016

345

trial_subscription

pandora_plus

1/1/2016

678

registered

ad_supported

1/1/2016

1230

subscription

pandora_premium

1/1/2016

123

subscription

pandora_plus

1/2/2016

345

trial_subscription

pandora_plus

1/2/2016

678

trial_subscription

pandora_plus

1/2/2016

1230

subscription

pandora_premium

1/2/2016

123

registered

ad_supported

1/3/2016

345

trial_subscription

pandora_plus

1/3/2016

678

trial_subscription

pandora_plus

1/3/2016

1230

subscription

pandora_premium

1/3/2016

Few clarification on the data

1.A listener can only appear once per day in this table.

2. Having a product_type of subscription indicates the listener is a subscriber.

3. A new subscriber would be one who did not have product_type of subscription the day before.

I'm trying to answer the following questions

1. Count of new subscribers that start paying each day.

2. Count of times a listener shows up as a new subscriber in the year

I was thinking of joining product_type of each user from previous day for all 365 days of the year and confirm whether they are a new subscriber or not. Wondering if the self join would be the most efficient way to go about. Any help appreciated.

sqlquery
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.