Re: query question for sql experts
Posted in 1998
Topics: SQL Development & Query Writing
Sorry, experts. I gave a bad example which may cause some confusion. One requirement to achieve this is to use only a pure SQL statement. Thanks. The following is a new example: TableA contains: EmpID GroupID CrDate 22 4 1/20/98 20 3 1/19/98 25 4 1/18/98 25 6 1/11/98 20 5 1/16/98 22 3 1/15/98 ... ... ... Expected query output: (Group by EmpID and order by lastest crdate first within each EmpID) EmpID GroupID CrDate 22 4 1/20/98 <- latest in crdate for a emp 22 3 1/15/98 20 3 1/19/98 <- second latest 20 5 1/16/98 25 4 1/18/98 <- 3rd latest 25 6 1/11/98 12 1/17/98 <- 4th latest 12 1/14/98 30 1/14/98 <- 5th latest 30 1/13/98 30 1/12/98 Leslie In article <6a3n9v$t8a$1@nntp6.u.washington.edu>, L. Tseng <lesliet@u.washington.edu> wrote: >Hi, SQL experts, > >Your help on the following qestion will be much appreciated. >For example: > >TableA contains: > > EmpID GroupID CrDate > 22 4 1/20/98 > 24 3 1/19/98 > 25 4 1/18/98 > 25 6 1/17/98 > 24 5 1/16/98 > 22 3 1/15/98 > >how do I get a query output like the following with pure SQL code: >(Group by EmpID and order by the lastest crdate first within each EmpID) > > EmpID GroupID CrDate > 22 4 1/20/98 > 22 3 1/15/98 > 24 3 1/19/98 > 24 5 1/16/98 > 25 4 1/18/98 > 25 6 1/17/98 >-- >=-=-=-=-=-=-=-=-=-=-= >Leslie Tseng >lesliet@writeme.com >=-=-=-=-=-=-=-=-=-=-= -- =-=-=-=-=-=-=-=-=-=-= Leslie Tseng lesliet@writeme.com =-=-=-=-=-=-=-=-=-=-=