One of the most powerful, yet counter-intuitive, theories in economics is about comparative advantage. Comparative advantage is when an agent can produce something for a lower marginal cost than other agents. Contrast that with absolute advantage, which is simply who can produce the good most efficiently. In free trade, agents should do what they are comparatively best at and not always what they are absolutely best at.
Engineers have an absolute advantage over PMs when it comes to writing SQL queries, but do engineers also have a comparative advantage? If PMs should write SQL queries, we would need to show that PMs have a lower marginal cost of writing SQL queries than engineers. The important assumptions:
In practice, we might consider fixed costs like how long it would take to give the PM access to the database and infrastructure, even though it may not contribute to marginal cost (our company may be a very finite timeline).
Let's compare costs in each bucket. Opportunity cost should be near equal for PMs and engineers if we're running a tight ship. For time cost, engineers can write queries faster and more correctly.