2,723
社区成员
发帖
与我相关
我的任务
分享
*--- VFP9.0(汉化版) 代码
*--- 文件版本:9.0.0.7423
Select id,acctno,BIANH,MAX(date) DATE From temp GROUP BY ACCTNO
create table temp (id int,acctno c(10),date c(10))
insert into temp values (1,'0001','20120102')
insert into temp values (2,'0001','20120103')
insert into temp values (3,'0002','20120102')
insert into temp values (4,'0002','20120104')
Select a.id,b.acctno,b.date From temp a,(Select acctno,Max(date) as date From temp Group By acctno ) b Where a.acctno = b.acctno And a.date = b.date
*-- vfp9.0 以下
Select id,acctno,Max(date) As date From table1 Group By acctno
*-- vfp9.0
Sys(3099,70)
Select id,acctno,Max(date) As date From table1 Group By acctno
Sys(3099,90)
Select max(id) As id,acctno,Max(date) As date From table1 Group By acctno
Create Table table1 (Id Int,acctno c(10),bianh c(10),Date c(10))
Insert Into table1 Values (1,'0001','1111','20120102')
Insert Into table1 Values (2,'0001','2222','20120103') && 取此条
Insert Into table1 Values (3,'0002','9999','20120102')
Insert Into table1 Values (4,'0002','6666','20120104') && 取此条
Browse && 看一下原始记录
Select * From table1 A Where Not Exists (Select 1 From table1 B Where A.acctno=B.acctno And A.Date<B.Date)
*-- 或
*-- 下面这句可能需要 vfp9.0
Select a.Id,b.acctno,a.bianh,b.Date From table1 a,(Select acctno,Max(Date) As Date From table1 Group By acctno ) b Where a.acctno = b.acctno And a.Date = b.Date