Should probably separate the lines:

```bash
DB=$(cylc get-global-config --print-run-dir)/$SUITE_NAME/cylc-suite.db
TASKS=$(sqlite3 $DB 'select count(*) from task_states where status is "failed"')
```

Note the reverse of the quotes for the 2nd statement.