SELECT 
  MIN(
    IF(
      shared_prices.product_id IS NOT NULL, 
      shared_prices.price, cscart_product_prices.price
    )
  ) as min, 
  MAX(
    IF(
      shared_prices.product_id IS NOT NULL, 
      shared_prices.price, cscart_product_prices.price
    )
  ) as max 
FROM 
  cscart_product_prices 
  LEFT JOIN cscart_products as products ON products.product_id = cscart_product_prices.product_id 
  LEFT JOIN cscart_product_prices as prices_2 ON cscart_product_prices.product_id = prices_2.product_id 
  AND cscart_product_prices.price > prices_2.price 
  AND prices_2.lower_limit = 1 
  AND prices_2.usergroup_id IN (0, 0, 1) 
  LEFT JOIN cscart_ult_product_prices AS shared_prices ON shared_prices.product_id = products.product_id 
  AND shared_prices.lower_limit = 1 
  AND shared_prices.usergroup_id IN (0, 0, 1) 
  AND shared_prices.company_id = 1 
  LEFT JOIN cscart_product_options_inventory as inventory ON inventory.product_id = products.product_id 
  INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id 
  INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id 
  AND (
    cscart_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
  LEFT JOIN cscart_product_popularity as popularity ON popularity.product_id = products.product_id 
WHERE 
  products.status IN ('A') 
  AND cscart_categories.category_id IN (20224) 
  AND cscart_categories.company_id = 1 
  AND (
    CASE products.tracking WHEN 'O' THEN inventory.amount > 0 WHEN 'B' THEN products.amount > 0 ELSE 1 END
  ) 
  AND (
    products.usergroup_ids = '' 
    OR FIND_IN_SET(0, products.usergroup_ids) 
    OR FIND_IN_SET(1, products.usergroup_ids)
  ) 
  AND products.status IN ('A') 
  AND cscart_product_prices.lower_limit = 1 
  AND cscart_product_prices.usergroup_id IN (0, 0, 1) 
  AND prices_2.price IS NULL

Query time 0.00244

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1.25"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "inventory",
          "access_type": "system",
          "possible_keys": [
            "pc"
          ],
          "rows_examined_per_scan": 0,
          "rows_produced_per_join": 1,
          "filtered": "0.00",
          "const_row_not_found": true,
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.10",
            "prefix_cost": "0.00",
            "data_read_per_join": "880"
          },
          "used_columns": [
            "product_id",
            "amount"
          ]
        }
      },
      {
        "table": {
          "table_name": "cscart_categories",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY",
            "c_status",
            "p_category_id"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "category_id"
          ],
          "key_length": "3",
          "ref": [
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.10",
            "prefix_cost": "0.00",
            "data_read_per_join": "2K"
          },
          "used_columns": [
            "category_id",
            "company_id",
            "usergroup_ids",
            "status"
          ]
        }
      },
      {
        "table": {
          "table_name": "products_categories",
          "access_type": "ref",
          "possible_keys": [
            "PRIMARY",
            "pt"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "category_id"
          ],
          "key_length": "3",
          "ref": [
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.99",
            "eval_cost": "0.10",
            "prefix_cost": "1.09",
            "data_read_per_join": "16"
          },
          "used_columns": [
            "product_id",
            "category_id"
          ]
        }
      },
      {
        "table": {
          "table_name": "products",
          "access_type": "eq_ref",
          "possible_keys": [
            "PRIMARY",
            "status"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "product_id"
          ],
          "key_length": "3",
          "ref": [
            "maniamall_cscart.products_categories.product_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 0,
          "filtered": "5.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.01",
            "prefix_cost": "1.19",
            "data_read_per_join": "224"
          },
          "used_columns": [
            "product_id",
            "status",
            "amount",
            "usergroup_ids",
            "tracking"
          ],
          "attached_condition": "((`maniamall_cscart`.`products`.`status` = 'A') and (0 <> (case `maniamall_cscart`.`products`.`tracking` when 'O' then <cache>((NULL > 0)) when 'B' then (`maniamall_cscart`.`products`.`amount` > 0) else 1 end)) and ((`maniamall_cscart`.`products`.`usergroup_ids` = '') or (0 <> find_in_set(0,`maniamall_cscart`.`products`.`usergroup_ids`)) or (0 <> find_in_set(1,`maniamall_cscart`.`products`.`usergroup_ids`))))"
        }
      },
      {
        "table": {
          "table_name": "popularity",
          "access_type": "eq_ref",
          "possible_keys": [
            "PRIMARY",
            "total"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "product_id"
          ],
          "key_length": "3",
          "ref": [
            "maniamall_cscart.products_categories.product_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 0,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.01",
            "prefix_cost": "1.19",
            "data_read_per_join": "1"
          },
          "used_columns": [
            "product_id"
          ]
        }
      },
      {
        "table": {
          "table_name": "cscart_product_prices",
          "access_type": "ref",
          "possible_keys": [
            "usergroup",
            "product_id",
            "lower_limit",
            "usergroup_id"
          ],
          "key": "usergroup",
          "used_key_parts": [
            "product_id"
          ],
          "key_length": "3",
          "ref": [
            "maniamall_cscart.products_categories.product_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 0,
          "filtered": "25.00",
          "cost_info": {
            "read_cost": "0.04",
            "eval_cost": "0.00",
            "prefix_cost": "1.24",
            "data_read_per_join": "0"
          },
          "used_columns": [
            "product_id",
            "price",
            "lower_limit",
            "usergroup_id"
          ],
          "attached_condition": "((`maniamall_cscart`.`cscart_product_prices`.`lower_limit` = 1) and (`maniamall_cscart`.`cscart_product_prices`.`usergroup_id` in (0,0,1)))"
        }
      },
      {
        "table": {
          "table_name": "prices_2",
          "access_type": "ref",
          "possible_keys": [
            "usergroup",
            "product_id",
            "lower_limit",
            "usergroup_id"
          ],
          "key": "usergroup",
          "used_key_parts": [
            "product_id"
          ],
          "key_length": "3",
          "ref": [
            "maniamall_cscart.products_categories.product_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 0,
          "filtered": "5.00",
          "not_exists": true,
          "cost_info": {
            "read_cost": "0.01",
            "eval_cost": "0.00",
            "prefix_cost": "1.25",
            "data_read_per_join": "0"
          },
          "used_columns": [
            "product_id",
            "price",
            "lower_limit",
            "usergroup_id"
          ],
          "attached_condition": "(<if>(found_match(prices_2), (`maniamall_cscart`.`prices_2`.`price` is null), true) and <if>(is_not_null_compl(prices_2), ((`maniamall_cscart`.`prices_2`.`lower_limit` = 1) and (`maniamall_cscart`.`cscart_product_prices`.`price` > `maniamall_cscart`.`prices_2`.`price`) and (`maniamall_cscart`.`prices_2`.`usergroup_id` in (0,0,1))), true))"
        }
      },
      {
        "table": {
          "table_name": "shared_prices",
          "access_type": "ref",
          "possible_keys": [
            "usergroup",
            "product_id",
            "company_id",
            "lower_limit",
            "usergroup_id"
          ],
          "key": "usergroup",
          "used_key_parts": [
            "product_id"
          ],
          "key_length": "3",
          "ref": [
            "maniamall_cscart.products_categories.product_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 0,
          "filtered": "100.00",
          "index_condition": "<if>(is_not_null_compl(shared_prices), ((`maniamall_cscart`.`shared_prices`.`company_id` = 1) and (`maniamall_cscart`.`shared_prices`.`lower_limit` = 1) and (`maniamall_cscart`.`shared_prices`.`usergroup_id` in (0,0,1))), true)",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.00",
            "prefix_cost": "1.25",
            "data_read_per_join": "0"
          },
          "used_columns": [
            "product_id",
            "price",
            "lower_limit",
            "company_id",
            "usergroup_id"
          ]
        }
      }
    ]
  }
}

Result

min max