If object_id (' [TB] ') is not null drop table [TB]
Go
CREATE TABLE [TB] ([SNO] int,[sname] varchar (4), [ssex] varchar (2), [Sbirthday] datetime,[class] int)
Insert [TB]
Select 108, ' Zeng Hua ', ' man ', ' 1905-05-22 00:00:00.000 ', 95033 UNION ALL
Select 105, ' Kuanming ', ' Male ', ' 1905-05-18 00:00:00.000 ', 95031 UNION ALL
Select 107, ' Wang Li ', ' female ', ' 1905-05-07 00:00:00.000 ', 95033 UNION ALL
Select 101, ' Li June ', ' male ', ' 1905-05-09 00:00:00.000 ', 95033 UNION ALL
Select 109, ' Wang Fang ', ' female ', ' 1905-05-18 00:00:00.000 ', 95031 UNION ALL
Select 103, ' Lu Jun ', ' Men ', ' 1905-05-20 00:00:00.000 ', 95031
Start--------------------------------Query------------------------------
SELECT * FROM [TB] where year (sbirthday) = (select year (sbirthday) from TB where [sno]=108)
/*
Sno Sname Ssex Sbirthday Class
----------- ----- ---- ----------------------- -----------
108 Zeng Hua men 1905-05-22 00:00:00.000 95033
105 Kuanming 1905-05-18 00:00:00.000 95031
107 Wang Liju 1905-05-07 00:00:00.000 95033
101 Li Junnan 1905-05-09 00:00:00.000 95033
109 Wang Fang female 1905-05-18 00:00:00.000 95031
103 Lu Junnan 1905-05-20 00:00:00.000 95031
(6 rows affected)
*/