Is it possible to utilize custom SQL for a single-post.php?

If you just want the ID of the requested post within the template, get_queried_object_id() will give you that.

If you want to modify the main query SQL before it’s executed, there are a number of filters that let you directly modify the SQL.

error code: 523