is a query that will return the most recent order for each customer. Let's
say the tables are like:
Customer: customerId, customerName
Orders: orderId, customerId, orderDate
The simple joins I've done give me back all of the orders for all of the
customers.
Any advice?Try
select * from customer c, orders o
where c.customerId = o.customerId
and c.orderId =
(
select max (o2.orderDate)
from orders o2
where o2.customerId = c.customerId
)
--
Regards Bagieta
~~~~~~~~~~~~~~~~~~~~~~~~~~~
dbDeveloper - Multiple databases editor
http://www.prominentus.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~
No comments:
Post a Comment