SELECT
cscart_product_prices.product_id,
MIN(
IF(
cscart_product_prices.percentage_discount = 0,
cscart_product_prices.price,
cscart_product_prices.price - (
cscart_product_prices.price * cscart_product_prices.percentage_discount
)/ 100
)
) AS price
FROM
cscart_product_prices
WHERE
cscart_product_prices.product_id IN (
1327, 1328, 1329, 1331, 1332, 1333, 1334,
1336, 1343, 1344, 1335, 1345
)
AND cscart_product_prices.lower_limit = 1
AND cscart_product_prices.usergroup_id IN (0, 1)
GROUP BY
cscart_product_prices.product_id