>Sir I have these codes
>
>
> CREATE CURSOR table1 (id int,names c(10),date d,qty int)
> INSERT INTO table1 VALUES (1,"ADMIN",{^2017-02-19},25)
> INSERT INTO table1 VALUES (1,"ADMIN",{^2017-02-20},21)
>
> INSERT INTO table1 VALUES (2,"GENERAL",{^2017-02-17},29)
> INSERT INTO table1 VALUES (2,"GENERAL",{^2017-02-21},14)
>
> SELECT id,MAX(names),MAX(date),MAX(qty)from table1 GROUP BY id
>
> brow
>
>
>it show these wrong result
>
>1 ADMIN 2/20/2017 25
>2 GENERAL 2/21/2017 29
>
>But I need this
>
>1 ADMIN 2/19/2017 25
>2 GENERAL 2/17/2017 29
>
>The date that has greater qty
>
>Later on I want to use these codes in SQLSERVER 2008
>
Thierry's given you the answer for VFP. In SQL Server 2012 and later, the OVER clause with LAST_VALUE gives you a better way to do this. I explain it in this paper:
http://www.tomorrowssolutionsllc.com/Conference%20Sessions/Going%20OVER%20and%20above%20with%20SQL.pdfTamar