Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Unanswered: 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!

  2. #2
    Join Date
    Dec 2003
    Posts
    17
    You could try:

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

  3. #3
    Join Date
    Mar 2004
    Posts
    5

    Thanks!

    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!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •