SQL语句出问题了,大家帮我看看!谢谢了.

yp7457177 2006-12-04 02:22:53

select s_number as 学号,
s_name as 姓名,
sex as 性别,
--year(getdate())-year(birthday) as 年龄
from t_student
where year(getdate())-year(birthday)<=25 and sex='男'
我想得到25岁以下的性别为男的结果.出错了.帮看一下.

where year(getdate())-year(birthday)<=25 and sex='男'这句有问题.我怎么改呀!
...全文
113 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yp7457177 2006-12-04
  • 打赏
  • 举报
回复
select s_number as 学号,
s_name as 姓名,
sex as 性别,
year(getdate())-year(birthday) as 年龄,
polity as 政治面貌
from t_student
where year(getdate())-year(birthday)<=25 and sex='男'

我这个也不错.
marco08 2006-12-04
  • 打赏
  • 举报
回复
--汗, 不到一分鍾就有10個回複
marco08 2006-12-04
  • 打赏
  • 举报
回复
where (year(getdate())-year(birthday))<=25 and sex='男'
--這樣率效不高
yp7457177 2006-12-04
  • 打赏
  • 举报
回复
谢谢.
playwarcraft 2006-12-04
  • 打赏
  • 举报
回复
出错了.帮看一下.
-----------------------
錯誤提示是什麼?
zjcxc 元老 2006-12-04
  • 打赏
  • 举报
回复
-- 如果要精度的25岁

where birthday > dateadd(year, -25, getdate()) and sex='男'
happydreamer 2006-12-04
  • 打赏
  • 举报
回复
select s_number as 学号,
s_name as 姓名,
sex as 性别,
datediff(year,birthday,getdate()) as 年龄
from t_student
where datediff(year,birthday,getdate())<=25
akuzou 2006-12-04
  • 打赏
  • 举报
回复
where datediff(year,birthday,getdate())<=25 and sex='男'
chuifengde 2006-12-04
  • 打赏
  • 举报
回复
where datediff(year,birthday,getdate())<=25
marco08 2006-12-04
  • 打赏
  • 举报
回复
where datediff(year, birthday, getdate())<=25 and sex='男'

34,593

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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