Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- a.item_id,
- a.price,
- a.mod_id,
- a.compl_id,
- i.*
- FROM (
- (SELECT * FROM some_table p WHERE p.price >= 400000 GROUP BY p.item_id ORDER BY p.price ASC LIMIT 5)
- UNION ALL
- (SELECT * FROM some_table p WHERE p.price < 400000 GROUP BY p.item_id ORDER BY p.price DESC LIMIT 5)
- ) a
- LEFT JOIN module_catalog_item i ON i.id = a.item_id
- ORDER BY ABS(a.price - 400000) ASC
- LIMIT 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement