declare @t table(a int,b int,c int,d int,e int) insert into @t select 1 ,2 ,3 ,4 ,5 union all select 3 ,2 ,1 ,0 ,7 union all select 3 ,4 ,3 ,2 ,9 union all select 4 ,5 ,1 ,3 ,6select * from @t x where not exists(select 1 from @t where c=x.c and a<x.a)--这样?
谢谢你的回复我对这个不是很精通,,能说一下 c=t.c and a>t.a 这个是什么意思吗?
Select A.* From 表1 A Inner Join (Select Min(A) As A,C From 表1 Group By C) B On A.A=B.A And A.C=B.C Order By A.D,A.F
declare @t table(id int,title varchar(20),imagesurl varchar(20),[update] datetime) insert into @t select 1,'aaaa','fsdfasdfasd','2006-1-1' union all select 2,'bbbb','fasdfasdfas','2006-1-2' union all select 3,'aaaa','fasdfasasad','2006-1-3' union all select 4,'bbbb','fasdfasdfas','2006-1-4' select * from @t x where not exists(select 1 from @t where title=x.title and [update]<x.[update])
一樣的啊,改成你對應的字段即可啊。Select A.* From 表1 A Inner Join (Select Min(id) As id,title From 表1 Group By title) B On A.id=B.id And A.title=B.title Order By A.[update],A.title
出错了Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005' [Microsoft][ODBC Microsoft Access Driver] 在查询定义的 SELECT 列表中,别名 'id' 循环引用。
ACCESS??try Select A.* From 表1 A Inner Join (Select Min(id) As Minid,title From 表1 Group By title) B On A.id=B.Minid And A.title=B.title Order By A.[update],A.title
select id,title,imagesurl,[update] from table a where 1>(select count(*) from table b where a.title=b.title and b.[update]<a.[update])
上面一个出现这个错误 Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14' [Microsoft][ODBC Microsoft Access Driver] 不能在 Memo、OLE 或超级链接对象 (B.Minid=A.id And B.title=A.title) 中连接。 下面一个 一直没有打开功,可能是数据太多的缘故,有2,3万个数据
又疏忽了一個地方,再試試這個Select A.* From 表1 A,(Select Min(id) As Minid,title From 表1 Group By title) B Where A.id=B.Minid And A.title=B.title Order By A.[update],A.title
insert into @t select 1 ,2 ,3 ,4 ,5
union all select 3 ,2 ,1 ,0 ,7
union all select 3 ,4 ,3 ,2 ,9
union all select 4 ,5 ,1 ,3 ,6select * from @t x where not exists(select 1 from @t where c=x.c and a<x.a)--这样?
A.* From
表1 A
Inner Join (Select Min(A) As A,C From 表1 Group By C) B
On A.A=B.A And A.C=B.C
Order By A.D,A.F
应该是
id,title,imagesurl,update
1,aaaa,fsdfasdfasd,2006-1-1
2,bbbb,fasdfasdfas,2006-1-2
3,aaaa,fasdfasasad,2006-1-3
4,bbbb,fasdfasdfas,2006-1-4要得出的结果就是,合并title相同的记录,然后按update和title排序结果应该是
1,aaaa,fsdfasdfasd,2006-1-1
2,bbbb,fasdfasdfas,2006-1-2
insert into @t select 1,'aaaa','fsdfasdfasd','2006-1-1'
union all select 2,'bbbb','fasdfasdfas','2006-1-2'
union all select 3,'aaaa','fasdfasasad','2006-1-3'
union all select 4,'bbbb','fasdfasdfas','2006-1-4' select * from @t x where not exists(select 1 from @t where title=x.title and [update]<x.[update])
A.* From
表1 A
Inner Join (Select Min(id) As id,title From 表1 Group By title) B
On A.id=B.id And A.title=B.title
Order By A.[update],A.title
[Microsoft][ODBC Microsoft Access Driver] 在查询定义的 SELECT 列表中,别名 'id' 循环引用。
Select
A.* From
表1 A
Inner Join (Select Min(id) As Minid,title From 表1 Group By title) B
On A.id=B.Minid And A.title=B.title
Order By A.[update],A.title
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'
[Microsoft][ODBC Microsoft Access Driver] 不能在 Memo、OLE 或超级链接对象 (B.Minid=A.id And B.title=A.title) 中连接。 下面一个
一直没有打开功,可能是数据太多的缘故,有2,3万个数据
A.* From
表1 A,(Select Min(id) As Minid,title From 表1 Group By title) B
Where A.id=B.Minid And A.title=B.title
Order By A.[update],A.title