Hello, Николай! You wrote on Wed, 07 Jun 2006 00:55:21 +0300: НВ> для получения прайс-листа с учетом скидок использую примерно такой НВ> страшный сиквел НВ> select НВ> p1.name, НВ> coalesce( НВ> price_1 * (select d1.discount_1 from x_discounts d1 where НВ> d1.seller_id = p1.seller_id and d1.product_id = p1.id), НВ> price_1 * (select d2.discount_1 from y_discounts d2 where НВ> d2.seller_id = p1.seller_id and d2.producer_id = p1.producer_id), НВ> price_1 * s1.discount_1 НВ> price_1) price_disc_1, НВ> coalesce( НВ> price_2 * (select d1.discount_2 from x_discounts d1 where НВ> d1.seller_id = p1.seller_id and d1.product_id = p1.id), НВ> price_2 * (select d2.discount_2 from y_discounts d2 where НВ> d2.seller_id = p1.seller_id and d2.producer_id = p1.producer_id), НВ> price_1) price_disc_2, НВ> from НВ> product p1 НВ> join proposals p2 on p1.id = p2.product_id НВ> join sellers s1 on p2.seller_id = s1.id
А почему ты не хочешь сджойнить с дискаунтами, а по два раза пишешь одинаковые подзапросы? НВ> from НВ> product p1 НВ> join proposals p2 on p1.id = p2.product_id НВ> join sellers s1 on p2.seller_id = s1.id left join x_discounts d1 on d1.seller_id = p1.seller_id and d1.product_id = p1.id -- With best regards, Andrei Yeryomin. --~--~---------~--~----~------------~-------~--~----~ -~----------~----~----~----~------~----~------~--~---

