我需要编写获取两个人年龄的程序,并从表中选择该年龄内所有人的名字和姓氏
这段代码会起作用吗?
CREATE PROCEDURE dbo.getEmployeeRange
@v_ageLow int,
@v_ageHigh int
AS
BEGIN
DECLARE
@v_dateLow date,
@v_dateHigh date
SET @d = CURDATE()
--convert age to date
@v_dateLow = DATEADD(year,-@v_ageLow,@d)
@v_dateHigh = DATEADD(year,-@v_ageHigh,@d)
SELECT firstName,lastName FROM employee
WHERE birthDate BETWEEN @v_dateLow and @v_dateHigh