Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Новые участники за неделю с 2015-02-02
- # ====================================================
- select
- u.registration_time,
- concat( u.name, ' ', u.surname) 'клиент',
- u.email, u.phone,
- u.last_call_description 'резюме',
- count( g.id) 'целей',
- sum( g.sum) 'взносы',
- concat( r.name, ' ', r.surname) 'Рег',
- rr.calling_user_time 'Взял',
- concat( k.name, ' ', k.surname) 'КМ'
- from users u
- join users_goals g
- on u.id = g.user_id
- and g.status <> 0
- and g.first_confirm_week_id is not null
- and g.queue_id = 4
- left join users k
- on k.id = u.client_manager_id
- left join users r
- on r.id = u.registration_user_id
- left join registrations rr
- on rr.user_id = u.id
- where u.registration_time >= '2015-03-16'
- and u.registration_time < date_add( '2015-03-16', interval 7 day)
- group by u.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement