Error with value 1 min ago - following example in docs

I have a sensor that reports thre value of another sensor but from one minute ago. I’m following the example in the docs (SQL - Home Assistant) and I’m getting an error. Are the docs right?

Here is my SQL query using the SQL integration:

  states.state
FROM
  states
  INNER JOIN states_meta ON
    states.metadata_id = states_meta.metadata_id
WHERE
  states_meta.entity_id = 'sensor.flume_sensor_87_current_month'
  AND last_updated_ts <= strftime('%s', 'now', '-1 minutes')
ORDER BY
  last_updated_ts DESC
LIMIT
  1;

Here is the error in the log:

Logger: homeassistant
Source: components/sensor/__init__.py:679
First occurred: December 25, 2024 at 5:26:32 AM (98 occurrences)
Last logged: 4:01:43 PM

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 677, in state
    numerical_value = float(value)  # type:ignore[arg-type]
ValueError: could not convert string to float: 'unavailable'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1055, in _async_update_entity_states
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 978, in async_update_ha_state
    self._async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1148, in _async_write_ha_state
    self.__async_calculate_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1085, in __async_calculate_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1029, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 679, in state
    raise ValueError(
    ...<5 lines>...
    ) from err
ValueError: Sensor sensor.flume_sensor_87_current_month_minus1min has device class 'water', state class 'total_increasing' unit 'Gal' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unavailable' (<class 'str'>)

I have to assume that the issue is that the original sensor wasn’t available… but, why doesn’t this example sql fail gracefully? What do i need to adjust on my end?

Thank you.