I have:

```
SELECT * FROM TABLE1 WHERE TIMESTAMP IN (SELECT TIMESTAMP FROM TABLE2 WHERE STATUS='1' AND TIMESTAMP_PROCESSED BETWEEN '2017-01-07-00.00.00.000000' and '2017-01-17-00.00.00.000000')

```

I got eight rows as result, four for TIMESTAMP '2017-01-09 11:26:29.434254' and other four for '2017-01-11 15:09:51.935322' with different TIMESTAMP\_OFFER(TABLE1 column). How could I get only latest TIMESTAMP\_OFFER for each TIMESTAMP? In other words, I only need two rows instead of eight.

Thanks.

UPDATE:

I have this query now:

```
SELECT TIMESTAMP, STATUS, MAX(TIMESTAMP_OFFER) FROM TABLE1 WHERE TIMESTAMP IN (SELECT TIMESTAMP FROM TABLE2 WHERE STATUS='1' AND TIMESTAMP_PROCESSED BETWEEN '2017-01-07-00.00.00.000000' and '2017-01-17-00.00.00.000000') GROUP BY TIMESTAMP, STATUS

```

But now I got result with four rows(two for each timestamp) because I have two STATUS values in each TIMESTAMP/TIMESTAMP OFFER:

```
-----------------------------------------------------------------------
| TIMESTAMP                  | STATUS | TIMESTAMP_OFFER               |
-----------------------------------------------------------------------
|2017-01-09 11:26:29.434254  | E      | 2017-02-01 16:05:02.221179    |
-----------------------------------------------------------------------
|2017-01-09 11:26:29.434254  | P      | 2017-02-01 16:05:02.221179    |
-----------------------------------------------------------------------
|2017-01-11 15:09:51.935322  | E      | 2017-02-11 12:00:50.410959    |
-----------------------------------------------------------------------
|2017-01-11 15:09:51.935322  | P      | 2017-02-11 12:00:50.410959    |
-----------------------------------------------------------------------

```

In this case, I only need this:

```
-----------------------------------------------------------------------
| TIMESTAMP                  | STATUS | TIMESTAMP_OFFER               |
-----------------------------------------------------------------------
|2017-01-09 11:26:29.434254  | E      | 2017-02-01 16:05:02.221179    |
-----------------------------------------------------------------------
|2017-01-11 15:09:51.935322  | E      | 2017-02-11 12:00:50.410959    |
-----------------------------------------------------------------------

```

How do I get it?