Friday, February 17, 2012

datediff or MAX?

Hello,

My string is:

SELECT weight FROM progress WHERE dateInput = (SELECT MAX(dateInput) FROM progress) AND memberID = 1

The problem is that the MAX dateInput doesn't belongs to memberID 1. It belongs to memberID 2. What I want is that I wanna choose the MAX Date of memberID 1. I thought of maybe using datadiff function. But I don't know how to make the datediff statement. Maybe I can write the datediff statement whereby the least datediff between the dateInput and getdate() will be the row I want. I really appreciate the person that helps me this problem... Thanks 1st of all!You could try:

SELECT weight FROM progress p WHERE dateInput = (SELECT MAX(dateInput) FROM progress p1 WHERE p1.memberID = p.memberID) AND memberID = 1|||The command it's made so simple by you! Thank you so so much! I really appreciate your help! Rushing my school assignment now, can't wait to finish it asap! =) With that sql command it really save alot of my brain juice!!! ;)

No comments:

Post a Comment