- SQL code
CREATE TABLE [dbo].[Wound]( [WoundID] [int] IDENTITY(1,1) NOT NULL, [Winding] [varchar](50) NULL, [TF_ID] [int] NULL, CONSTRAINT [PK_Wound] PRIMARY KEY CLUSTERED ( [WoundID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]GOinsert into Wound values('NP1',1)insert into Wound values('NP1',1)insert into Wound values('NP2',1)insert into Wound values('NP3',1)insert into Wound values('NP2',1)insert into Wound values('NP3',2)insert into Wound values('NP3',2)insert into Wound values('NP1',2)insert into Wound values('NP1',2)
我想要的结果是
WoundID Winding TF_ID
1 NP1 1
3 NP2 1
4 NP3 1
6 NP2 2
8 NP1 2
不用ROW_NUMBER() over(partition by........
服务器的数据是2000的, 求解
------解决方案--------------------
- SQL code
select * from Wound T where not exists (select 1 from Wound where T.[Winding]=[Winding] and T.[TF_ID]=[TF_ID] And T.[WoundID]>[WoundID] )