Hey, I am having a problem with a SQL statement. I hope someone can help me.
I have a table with one key column, ID and two columns, Value and Date. I have a variable that contains a certain date. I need to select the max value whose date is less than my variable!
This gives me ALL the values less than my variable, not just the max value less than my variable :(. Please help.
I have a table with one key column, ID and two columns, Value and Date. I have a variable that contains a certain date. I need to select the max value whose date is less than my variable!
Code:
SELECT Value ,MAX(Date) FROM myTable WHERE ID= '565' GROUP BY Value HAVING MAX(Date) <= @Variable
Comment