Hi everyone!what do you guys think of this query! select count(*) [Population],DG.GroupAge from (select ms.dob,case when datediff(YEAR,ms.dob,getdate())< 10 then 'G10'when datediff(YEAR,ms.dob,getdate()) between 10 and 19 then 'G 10-20'when datediff(YEAR,ms.dob,getdate())between 20 and 29 then 'G 20-30'when datediff(YEAR,ms.dob,getdate())between 30 and 39 then 'G 30-40'when datediff(YEAR,ms.dob,getdate())between 40 and 49 then 'G 40-50'when datediff(YEAR,ms.dob,getdate())between 40 and 49 then 'G 50-60'else 'G60+' end as GroupAge from people ms where ms.id in (select max(id) from dbo.table group by customer_id) and ms.location in ('CO','TX')) as DGGroup by DG.GroupAgeOrder by GroupAge
It runs fine! just want to see if any improvement I can add.Thanks--------------------------Joins are what RDBMS's do for a living