Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. # Новые участники за неделю с 2015-02-02
  2. # ====================================================
  3.  
  4. select
  5. u.registration_time,
  6. concat( u.name, ' ', u.surname) 'клиент',
  7. u.email, u.phone,
  8. u.last_call_description 'резюме',
  9. count( g.id) 'целей',
  10. sum( g.sum) 'взносы',
  11. concat( r.name, ' ', r.surname) 'Рег',
  12. rr.calling_user_time 'Взял',
  13. concat( k.name, ' ', k.surname) 'КМ'
  14. from users u
  15. join users_goals g
  16. on u.id = g.user_id
  17. and g.status <> 0
  18. and g.first_confirm_week_id is not null
  19. and g.queue_id = 4
  20. left join users k
  21. on k.id = u.client_manager_id
  22. left join users r
  23. on r.id = u.registration_user_id
  24. left join registrations rr
  25. on rr.user_id = u.id
  26. where u.registration_time >= '2015-03-16'
  27. and u.registration_time < date_add( '2015-03-16', interval 7 day)
  28. group by u.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement