I am having a few issues making a MAX function work within the select statement See example data below:
Table 1                   Table 2
Visit_ID Car_ID        Move_ID  Visit_ID  MoveStartDate  MoveEndDate
A          1              1        A      25/07/2016     27/07/2016 
B          2              2        A      28/07/2016     28/07/2016   
C          1              3        B      19/07/2016     22/07/2016 
D          3              4        D      28/06/2016     30/06/2016
I would like my select statement to pick the min start time and Max start time based on the Visit_ID so I would be expecting:
Result
Visit_ID   Car_ID  StartDate   EndDate
A           1      25/07/2016  28/07/2016
B           2      19/07/2016  22/07/2016
So far I have tried I already have Inner Joins in my select statement:
,(MAX (EndDate) WHERE Visit.Visit_ID = Move.Visit_ID) AS End Date
I have looked at some other queries with a second select statement within the select so you end up with something like:
Select Visit_ID, Car_ID ,(Select MAX(EndDate) FULL OUTER JOIN Table 2 ON Table 1.Visit_ID = Table 2.Visit_ID Group By Table 1.Visit_ID) AS End Date
Hope I have provided enough info currently stumped.
 
     
    