{% set result = sql("SELECT COUNT(*) from highlight WHERE book_id = :book_id", { "book_id": book.id}) %} {% set count = result[0][0] %}