jdm_mysql_query_cached(WITH RankedRelations AS (
SELECT
id,
node1,
node2,
type,
w,
ROW_NUMBER() OVER (PARTITION BY type ORDER BY w DESC) AS rank_desc,
ROW_NUMBER() OVER (PARTITION BY type ORDER BY w ASC) AS rank_asc
FROM Relations
WHERE node1 = 0
)
SELECT
id,
node1,
node2,
type,
w
FROM RankedRelations
WHERE rank_desc <= 20 OR rank_asc <= 20
ORDER BY type, w DESC; ...
Le Diko - perturb�>145664