Want to list status sensors with specific status but get then also sensors which had that status previously

Here example data to clairify my question, the query is done in Grafana.

time   building  sensorName  sensorType  status   sensorTitle
10:00  A         sensor_1    smoke       online   Smoke_kitchen
10:05  A         sensor_2    door        offline  Front_door
10:07  A         sensor_3    window      online   livingroom_window
11:01  A         sensor_2    door        online   Front_door
11:03  A         sensor_3    window      offline  livingroom_window

Tags are: building, sensorName, sensorType, status

When I want to make a list from online and a list from offline sensors it got mixed up:
Online:

building  sensorName  sensorType  sensorTitle
A         sensor_1    smoke       Smoke_kitchen
A         sensor_2    door        Front_door
A         sensor_3    window      livingroom_window

Offline:

building  sensorName  sensorType  sensorTitle
A         sensor_2    door        Front_door
A         sensor_3    window      livingroom_window

The query I used (for offline query the status = offline):
SELECT last(“sensorTitle”) FROM “sensorData” WHERE (“building” = ‘A’ AND “status” = ‘online’) AND $timeFilter GROUP BY “building”, “sensorName”, “sensorType”

Now it is selecting on the status online/offline and not the last entry and then only the once which are online or offline. Hereby in this example sensor_3 should not be seen in the online list and sensor_2 not in the offline list. How can I arrange the query so I have the correct last status overview