私は次のmysqlクエリを持っています:
SELECT merchantNames.strippedName,merchantNames.lastCached,merchantNames.id
FROM merchantNames
JOIN autoCoupons
ON merchantNames.rawName = autoCoupons.merchantName
WHERE NOW() > autoCoupons.startDate AND autoCoupons.startDate > merchantNames.lastCached
OR NOW() > autoCoupons.endDate AND autoCoupons.endDate > merchantNames.lastCached
OR NOW() > autoCoupons.timeAdded AND autoCoupons.timeAdded > merchantNames.lastCached
OR merchantNames.lastCached < NOW() - INTERVAL 2 DAY
GROUP BY merchantNames.strippedName
ORDER BY merchantNames.pageviews DESC
WHERE句の基準の最初の3行を満たすものが上になり、下の行だけを満たすものが下になるように結果を並べ替えるには、このクエリを設定するにはどうすればよいですか?