【发布时间】:2011-05-13 17:48:45
【问题描述】:
我怎样才能把它翻译成 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
谢谢!
【问题讨论】:
-
万一有人遇到这个并想知道“它们之间有什么区别”,也许只有一个是重复的:stackoverflow.com/questions/436028/linq-to-sql-case-query并且它没有在标题中指定范围,但它就是答案。其他仅限于案例陈述,但在特定场景中。实际问题中标记的答案与问题指定的范围无关......所以......
标签: c# sql linq tsql linq-to-sql