Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user_id email gender age name
- 1 a@a.com m 30 rob
- 2 a@a.com m 31 robert
- 3 b@b.com f 18 lucie
- 4 b@b.com f 22 lulu
- 5 c@c.com m 10 kim
- 6 c@c.com f 18 kim
- 7 c@c.com f 08 kim
- 8 d@d.com f 18 JJ
- 9 d@d.com m 22 Jay
- 10 e@e.com f 88 Bill
- 11 e@e.com f 88 Will
- 12 e@e.com f 60 Will
- 13 f@f.com m 70 George
- subscription_id user_id subsciption_type active_indicator
- 1 2 Magazine Yes
- 2 3 Music CD No
- 3 3 Magazine Yes
- 4 3 Video Yes
- 5 8 Magazine Yes
- 6 9 Video Yes
- 7 10 Magazine No
- 8 13 Magazine yes
- subscription_id action timestamp
- 1 Renewal 2002-sep-10
- 2 Renewal 2002-Jan-01
- 2 Cancellation 2002-Feb-01 ,
- 3 Renewal 2002-Aug-20
- 4 Renewal 2002-Aug-01
- 4 Renewal 2002-Sep-01
- 5 Renewal 2002-Aug-01
- 6 Renewal 2001-Sep-01
- 7 Renewal 2002-Sep-01
- 7 Cancellation 2002-Sep-10
- a@a.com m 31 robert
- b@b.com f 22 lulu
- c@c.com f 08 kim
- d@d.com m 22 Jay
- e@e.com f 60 Will
- select u.user_id, email, gender, age, name
- from users u left join subscriptions s
- on u.user_id = s.user_id
- where s.user_id is null
- or s.active_indicator='No'
- or u.user_id in (
- select u.user_id
- from subscriptions s,transactions t, users u
- where u.user_id = s.user_id
- and s.subscription_id = t.subscription_id
- and t.`action`='Renewal'
- and s.active_indicator='Yes'
- and month(timestamp) = 9
- )
- 1 a@a.com m 30 rob
- 4 b@b.com f 22 lulu
- 5 c@c.com m 10 kim
- 6 c@c.com f 18 kim
- 7 c@c.com f 8 kim
- 11 e@e.com f 88 will
- 12 e@e.com f 60 will
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement