I have to write a query with the following requirements:

> 
> The query should return a list of all
>  entry values for a customer named
>  “Steve” and for each date shown (if
>  available) the most recent status detail for 
>  that date.
> 
> 
> 

**Customer Table** 

```
CustomerID | CustomerName
1          |    Steve
2          |    John

```

**Entry Table** 

```
CustomerID | EntryDate | EntryValue 
 1         | 5/4/2010  |    200.0  
 1         | 4/4/2010  |    100.0  
 1         | 3/4/2010  |    150.0
 1         | 2/4/2010  |    170.0
 2         | 5/4/2010  |    220.0

```

**Status Table**

```
CustomerID | StatusDate | Detail
1          | 5/28/2010  | D
1          | 4/24/2010  | S
1          | 4/5/2010   | P
1          | 2/28/2010  | A

```

The expected output is:

```
CustomerName |   Date    |   OrderCost |   Detail 
  Steve      | 5/4/2010  |    200.0    |  S
  Steve      | 4/4/2010  |    100.0    |  A
  Steve      | 3/4/2010  |    75.0     |  A
  Steve      | 3/4/2010  |    75.0     |  <null>

```

I think that the expected output may be wrong and it should actually be:

```
CustomerName |   Date    |   OrderCost |   Detail 
  Steve      | 5/4/2010  |    200.0    |  S
  Steve      | 4/4/2010  |    100.0    |  A
  Steve      | 3/4/2010  |    150.0     |  A
  Steve      | 2/4/2010  |    170.0     |  <null>

```

Given the requirement, I don't understand why the 3/4/2010 date would occur twice and the second time it would have a Detail. I wrote the following query:

I wrote the following query:

```
SELECT  Customers.CustomerName, Entries.EntryDate, Entries.EntryValue, Status.Detail
FROM   Customers
    INNER JOIN Entries ON Customers.CustomerID = Entries.CustomerID
    LEFT OUTER JOIN Status ON Status.CustomerID = Customers.CustomersID AND Status.StatusDate <= Entries.EntryDate
WHERE (Customers.CustomerName = 'Steve')

```

The result of my query is this: 

```
CustomerName| EntryDate |   EntryValue |   Detail
Steve      |  5/4/2010 |    200.00  |   S
Steve      |  5/4/2010 |    200.00  |   P
Steve      |  5/4/2010 |    200.00  |   A
Steve      |  4/4/2010 |    100.00  |   A
Steve      |  3/4/2010 |    150.00  |   A
Steve      |  2/4/2010 |    170.00  |   NULL

```

Any hints on what I'm doing wrong here? I can't figure it out...

**Update**
I've changed the order to an entry so it doesn't confuse us that much.