Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- concat(10*floor(age/10), '-', 10*floor(age/10) + 10) as `range`,
- count(*) as count
- from (
- select
- TIMESTAMPDIFF(YEAR, customers.birthdate, CURRENT_DATE()) AS age
- from
- customers inner join vehicles on customers.id = vehicles.customer_id
- where
- customers.birthdate IS NOT NULL
- AND vehicles.branch_code = 'H360'
- ) as t
- group by `range`
- ORDER BY `range`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement