how can I translate this into LINQ?
select t.age as AgeRange, count(*) as Users from ( select case when age between 0 and 9 then ' 0-25' when age between 10 and 14 then '26-40' when age between 20 and 49 then '60-100' else '50+' end as age from user) t group by t.age
Thank you!
Maybe this works:
from u in users let range = (u.Age >= 0 && u.Age < 10 ? "0-25" : u.Age >= 10 && u.Age < 15 ? "26-40" : u.Age >= 15 && u.Age < 50 ? "60-100" : "50+") group u by range into g select new { g.Key, Count=g.Count() };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With