Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.39 KB | None | 0 0
  1. select
  2.   concat(10*floor(age/10), '-', 10*floor(age/10) + 10) as `range`,
  3.   count(*) as count
  4. from (
  5.   select
  6.     TIMESTAMPDIFF(YEAR, customers.birthdate, CURRENT_DATE()) AS age
  7.   from
  8.     customers inner join vehicles on customers.id = vehicles.customer_id
  9.    where
  10.     customers.birthdate IS NOT NULL
  11.     AND vehicles.branch_code = 'H360'
  12. ) as t
  13. group by `range`
  14. ORDER BY `range`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement