关于人数统计,帮顶又分~~~

soft1000_hb 2008-03-18 01:26:11
我想统计1980-01-01以后出生的人员数量,Birthday为DateTime型,语句
set @m = convert(int,'sum(case when Birthday<=convert(varchar(10),1980-01-01,120) then 1 else 0)')
一直报错,数据表为UserInfo,小弟初学SQL,望各位高手指点迷津~
谢谢~~~~
...全文
62 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
pt1314917 2008-03-18
  • 打赏
  • 举报
回复
1980-01-01后出生的啊,疯子
wzy_love_sly 2008-03-18
  • 打赏
  • 举报
回复
日 掉线了
他们怎么都是>?
wzy_love_sly 2008-03-18
  • 打赏
  • 举报
回复
create table tb(Birthday datetime)
insert into tb select '1979-01-01'
insert into tb select '1978-01-01'
insert into tb select '1977-01-01'

declare @m int
select @m=count(1) from tb where Birthday <cast('1980-01-01' as datetime)+1
select @m


3
soft1000_hb 2008-03-18
  • 打赏
  • 举报
回复
谢谢,各位高手~~~
pt1314917 2008-03-18
  • 打赏
  • 举报
回复

declare @m int
select @m=count(1) from userinfo where Birthday> ='1980-01-01'
select @m
gahade 2008-03-18
  • 打赏
  • 举报
回复

select count(*) from UserInfo where Birthday>'1980-01-01'
hlq8210 2008-03-18
  • 打赏
  • 举报
回复
select count(1) from userinfo where Birthday>='1980-01-01'
wzy_love_sly 2008-03-18
  • 打赏
  • 举报
回复
帮顶

27,580

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧