我怎样才能把它翻译成 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
谢谢你!
也许这有效:
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() };
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)