如何比较两个年龄一个年龄,其他年龄计算年龄为ms sql server2008
WHERE sites.site_type = 3 AND o.order_date > '2015-10'
我得到fname,lname和calcAge
这是表中给出的年龄
select FNAME,LNAME, cast(datediff(DAY,DOB, '03-OCT-2015') /
(365.23076923074) as int) as 'calcAge' from students1 order by Age asc
这个calcage需要与学生表中的年龄进行比较,如果该年龄匹配则应该返回true,否则
insert into students values(1, 'Jon', 'Smith', 30, '10-FEB-2000');
insert into students values(2, 'Jane', 'Smith', 20, '12-FEB-1993');
insert into students values(3, 'Joan', 'Smith', 75, '16-OCT-1938');
insert into students values(4, 'Joanne', 'Smith', 18, '20-JUN-1995');
它的返回错误。请纠正我
答案 0 :(得分:0)
select FNAME
,LNAME
,Age
, cast(datediff(DAY,DOB, '03-OCT-2015') /(365.23076923074) as int) as 'calcAge'
, CASE WHEN cast(datediff(DAY,DOB, '03-OCT-2015') /(365.23076923074) as int)
= Age
THEN 1 ELSE 0 END AS AgeCompare
from students1
order by Age asc
答案 1 :(得分:0)
以下是如何将给定年龄与T-SQL中的计算年龄进行比较
>"0"