Selecting the last record for each customer

Selecting the last record for each customer

Post by Scott David Daniel » Thu, 17 Sep 1998 04:00:00

Or a more efficient version
(perhaps -- no correlated subquery).

select COR_ID,  CLIENT, DATESent,  Letter
From Table1
Where cor_id IN (select max(cor_id)
                from table1 group by client)

-Scott David Daniels

> here is a simple query that should work for you.
> select COR_ID,  CLIENT, DATESent,  Letter
> From Table1 A
> Where cor_id = (select max(cor_id)
>                          from table1 B
>                          where a.client = b.client)
> -------------------


1. Best SQL for Joing Customer and last customer Transaction

Dear All,
  There is a table Customer with
       CustomerID: (Primary Key)

  and a table Transaction which holds all the transactions
       TransID: (Primary Key)

  What is the BEST SQL or Best way to get all the
customer's LAST transaction with customer name,
  The result should be
    CustomerName    LastTransDate
    ------------    -------------
     Peter           2003/1/1
     Mary            2003/7/1
     Paul            2003/8/1


2. error 14277 , request to destroy object created

3. how to select the last record?

4. Distribution Database Options

5. Select last record

6. Help with ODBC

7. SELECT 2nd to last Records

8. A connection could not be established to DA005034 - [SQL Server] Login Failed

9. Selecting the last inserted record

10. How to select last record in query

11. SELECT TOP and the last record

12. Select LAST record from group

13. LAST record in Select statement