Sunday, February 19, 2012

DataBase Query help

Here's my situation:

I've got a column in one table called PRODID, and each value in this column references 1 or more values, say OrderDates, and I was wondering whether it's possible to write a query that returns all the values in the PRODID along with the latest OrderDate of the relevant PRODID value into the following result set:

PRODID OrderDate
1 "Latest Date"
2 "Latest Date"

And so on. Latest Date refers to the DateTime shown under OrderDates.

All help appreciatedSELECT P.ProductID, MAX(O.OrderDate)
FROM Orders O
INNER JOIN Products P ON O.ProductID = P.ProductID
GROUP BY P.ProductID|||Thanks for that, but I was just wondering is there any way to modify that query so that if any values for ProdID do not have an orderDate, the result set also returns these ProdIds but with a null value for the OrderDate?|||Actually ignore my last post, I managed to modify it to suit my eact needs, thanks for showing me the code though

No comments:

Post a Comment