I have a table that looks like this:
+------------+------------+--------+----------+--------------+
| terminalid | date | toolid | toolname | workcenterid |
+------------+------------+--------+----------+--------------+
| 17 | 2015-12-17 | 132 | RE8 | 7 |
| 17 | 2015-12-17 | 140 | RE77 | 10 |
| 17 | 2015-12-17 | 141 | RE0 | 1 |
| 17 | 2015-12-17 | 153 | RTR | 13 |
| 18 | 2015-12-18 | 29 | C47 | 12 |
| 18 | 2015-12-18 | 53 | C45 | 10 |
| 18 | 2015-12-18 | 58 | TXR | 9 |
| 18 | 2015-12-18 | 61 | BMS | 6 |
| 19 | 2015-12-21 | 128 | REV | 3 |
| 19 | 2015-12-21 | 135 | REZS | 12 |
| 19 | 2015-12-21 | 154 | REP | 1 |
| 20 | 2015-12-22 | 21 | RR14 | 9 |
| 20 | 2015-12-22 | 69 | REX | 1 |
| 20 | 2015-12-22 | 71 | REA | 4 |
| 20 | 2015-12-22 | 72 | REW | 11 |
| 20 | 2015-12-22 | 91 | RER | 1 |
+------------+------------+--------+----------+--------------+
I want to get the last 2 terminalids from the rows where the date is today or yesterday.
For example, if today was 2015-12-18, the query should return me this:
+------------+------------+--------+----------+--------------+
| terminalid | date | toolid | toolname | workcenterid |
+------------+------------+--------+----------+--------------+
| 17 | 2015-12-17 | 132 | RE8 | 7 |
| 17 | 2015-12-17 | 140 | RE77 | 10 |
| 17 | 2015-12-17 | 141 | RE0 | 1 |
| 17 | 2015-12-17 | 153 | RTR | 13 |
| 18 | 2015-12-18 | 29 | C47 | 12 |
| 18 | 2015-12-18 | 53 | C45 | 10 |
| 18 | 2015-12-18 | 58 | TXR | 9 |
| 18 | 2015-12-18 | 61 | BMS | 6 |
+------------+------------+--------+----------+--------------+
If today was 2015-12-19, then only the terminalid=18 rows should be returned. And if today was, for instance, 2015-12-20, no rows should be returned, because there is no data either for today or for yesterday.
How can I achieve that?
I'm using SQL Server.