Allocation queries in sql format