Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need Last Record

eman2aeman2a Member Posts: 15
I have a table of orders. Some customers have multiple orders. I need to select only the last order for each customer. Can someone show me how I can do this.

Thanx,
Jim

Jim (eman2a)

Comments

  • kapiloo7kapiloo7 Member Posts: 45
    May be i am late to answer but hope it may help u.
    suppose this is (or might be) the table structure.

    Customer:
    custid, custname, address,....

    Order:
    Orderid, custid, orderdate,....


    Select * from Orders
    Where Orderid in
    (Select Orderid
    From Order, Customer
    Where Order.Custid = Customer.Custid
    group by Customer.custid
    having orderdate = max(orderdate))


    : I have a table of orders. Some customers have multiple orders. I need to select only the last order for each customer. Can someone show me how I can do this.
    :
    : Thanx,
    : Jim
    :
    : Jim (eman2a)
    :

Sign In or Register to comment.