Skip to content
Forum arrow Programmingarrow Databasearrow Trouble getting latest record for a given item
+  MyPlace
|-+  Programming» Database» Trouble getting latest record for a given item
Username:
Password:
Pages: [1]   Go Down
  Print  
Author Topic: Trouble getting latest record for a given item  (Read 301 times)
AWAY
Newbie
*
Posts: 3


« on: November 12, 2007, 12:05:15 PM »

I haven't found the information I seek in the manual yet, but I
continue to look. I am hoping that someone will give me a clue in the
mean time; hoping to shorten the time I need to fix this.

I tried the following:

SELECT *, max(price_date) FROM prices GROUP BY product_id WHERE
product_id = 1 AND price_date = max(price_date);

There is no knowing what the latest date is for a given item in the
DB.

But if I don't have the GROUP BY clause I get an error about misusing
max(), and using it, I still get an uninformative error about my WHERE
clause.

What I want ought to be obvious: the latest price for a given
product. How do I fix this SELECT statement to get what I want?

Thanks
_________________
bat control free windows registry cleaner
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Page created in 0.048 seconds with 20 queries.