现在业务需求如下:需要查询表特定列的指定月份等信息
表结构如下:
create table ShowT(
Id int primary key identity(1,1),
Name nvarchar(50),
Value decimal(18,5),
ShowTime date
)
insert into ShowT values('s1',null,'2018-01-01')
insert into ShowT values('s1',null,'2019-01-01')
insert into ShowT values('s2',1,'2019-02-01')
insert into ShowT values('s3',null,'2019-03-01')
insert into ShowT values('s4',3,'2019-04-01')
select * from ShowT
需求1 :我们要查询所有2019年的信息
select * from ShowT where ShowTime like'%2019%'
<