Yes either via bookshelf or even RAW Knex queries, it’s just not generally recommended. If it’s a very hard requirement you could though. (Or if you are a mongoose user, it’s also possible there too)
https://strapi.io/documentation/developer-docs/latest/concepts/queries.html#custom-queries