Max

NathanSavidge

Registered User.
Local time
Today, 17:32
Joined
Apr 19, 2010
Messages
12
I am trying to find out the latest change in an audit table, by using the max function. However, it is not working, and i am having
trouble with a sub query as i have 2 criteria, the task ID and the date changed. I want to know the latest change new_value
in a task using task_ID, based on the date_changed being less than or equal to the date being queried from the table
task_audit_ID, Task_ID, Date_Changed, Old_Value, New Value
1 1 20/04 10 20
2 1 23/04 20 25
3 1 25/04 25 30

so querying for 24/04 would show New Value of 25


TIA
 
How about

WHERE TaskID = 1 AND Date_changed <= 24/04

Hopefully that's actually a date/time field.
 
Paul I suspect that he is trying to use Max to get the max date and extract the new value at the same time,

Nathan that cannot be done, max is a field operator, you need to run 2 queries the first group by taskId and max date_changed, this is then joined back to the table on those two fields to extract any other data.

Brian
 
And Paul has an iPhone, therefore BaldyWeb has apps! :p
 

Users who are viewing this thread

Back
Top Bottom