Inner Join or what else? What I have

Table A                                 Table B


ID    ID_Fruit    ,,, so on             ID      ID_Fruit   ID_CRATE  DateTime                
1     1002                              i_1     1002          1      2014-07-28 00:00.000
2     4534                              i_2     1002          2      2014-06-25 00:00.000
3     1243                              i_3     1243          NULL   2014-07-09 00:00.000
4     1003                              i_4     4534          1      2014-07-23 00:00.000`


Result I want:

ID    ID_Fruit    ,,, so on             ID      ID_Fruit    ID_CRATE     DateTime
1     1002                              i_1     1002           2      2014-06-25 00:00.000
2     4534                              i_4     4534           1      2014-07-23 00:00.000


What I am trying,

SELECT * 
FROM TABLEA
    OUTER APPLY  
        (SELECT * 
         FROM TableB 
         WHERE TableB.ID_Fruit = TableA.ID_Fruit 
           AND TableB.ID_CRATE IS NOT NULL
        ) As Table_B


I want only 1 row from several rows in Table B based on closest DateTime
Yes, shouldn't be too difficult, try:

SELECT a.ID, a.ID_Fruit,,, so on b.ID, b.ID_Fruit, b.ID_Crate, b.[DateTime]
FROM TABLEA a
INNER JOIN TABLEB b ON a.ID_Fruit = b.ID_Fruit
INNER JOIN (SELECT ID_Fruit, MAX([DateTime]) FROM TABLEB GROUP BY ID_FRUIT) maxtime 
      ON b.[DateTime] = maxtime.[DateTime]


Its not quite clear if you mean that it should be the most recent, but I have assumed that is what you mean.