AnsweredAssumed Answered

Using SQL, Return other fields with aggregate function

Question asked by PJSpark on Feb 28, 2013
Latest reply on Mar 1, 2013 by PJSpark

Title

Using SQL, Return other fields with aggregate function

Post

     Hello,

     I have been unsuccessful in retrieving a min. or max value from a field along with other fields, like a date.

     I'm trying to get a min (or max) value, which is easy enough, but I also want to be able to access other fields in the record, such as a date when the min. occurred. That part I haven't been able to figure out.

     I've tried together like:   "SELECT  MIN(\"E Used\"),\"Read Date\"  FROM \"Data\"  WHERE \"E Used\" > 0 GROUP BY \"Read Date\" HAVING \"E Used\" = MIN(\"E Used\")"

     And in two separate:   M="SELECT MIN(\"E Used\") FROM \"Data\" WHERE \"E Used\" > 0" 

       D= "  SELECT  \"Read Date\"  FROM \"Data\"  WHERE \"E Used\" =" & M
      
     In the separate one, the second select never seems to match the value from the first select, so no date is returned
      
     Thanks,
      
      

Outcomes