求高手帮忙,在线等。
CREATE TABLE [Table1] (
[a] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[b] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[c] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[d] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[e] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[f] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[g] [char] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[h] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[i] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[j] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[k] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[l] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[m] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[n] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[o] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[p] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[q] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[r] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[s] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[t] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[u] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[v] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[w] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[x] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[y] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[z] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED
(
[g]
) ON [PRIMARY]
) ON [PRIMARY]
GO
Insert Into table1
(d,e,f,g)
Values
('1','1','1','a')
Insert Into table1
(d,e,f,g)
Values
('1','1','1','b')
Insert Into table1
(d,e,f,g)
Values
('2','1','1','c')
Insert Into table1
(d,e,f,g)
Values
('2','1','1','e')
Insert Into table1
(d,e,f,g)
Values
('3','1','3','d')
select * from table1 as a
where f=(select max(b.f)
from table1 as b
where a.d = b.d and a.e=b.e
);
[
本帖最后由 shmhms2015 于 2015-8-10 13:00 编辑 ]