SELECT
cscart_ult_product_prices.product_id,
MIN(
IF(
cscart_ult_product_prices.percentage_discount = 0,
cscart_ult_product_prices.price,
cscart_ult_product_prices.price - (
cscart_ult_product_prices.price * cscart_ult_product_prices.percentage_discount
)/ 100
)
) AS price
FROM
cscart_ult_product_prices
WHERE
cscart_ult_product_prices.product_id IN (
101689, 101688, 102270, 102269, 102268,
101746, 101745, 101744, 101743, 101615,
101614, 101960, 101569, 101568, 101567,
101566, 101540, 101539, 101969, 102183
)
AND cscart_ult_product_prices.lower_limit = 1
AND cscart_ult_product_prices.company_id = 1
AND cscart_ult_product_prices.usergroup_id IN (0, 0, 1)
GROUP BY
cscart_ult_product_prices.product_id