DK
Size: a a a
DK
DK
DK
DK
YS
DK
DK
YS
DK
DK
YS
YS
SELECT *если ничего не перепутал.
FROM offers
LEFT JOIN application_offers AS ApplicationOffers
ON ApplicationOffers.application_id = 2
AND offers.id = ApplicationOffers.offer_id
WHERE EXISTS (
SELECT 1
FROM shops
INNER JOIN countries
ON countries.id = 2 AND countries.id = shops.country_id
WHERE shops.id = offers.shop_id
)
ORDER BY Offers.is_active DESC NULLS LAST,
ApplicationOffers.is_active DESC NULLS LAST,
Offers.expires ASC NULLS LAST
LIMIT 20 OFFSET 0;
DK
DK
DK
YS
DK
YS
YS