我必须通过 Levenshtein 函数处理我的数据。 在这种情况下,我使用嵌套选择
SELECT levenshtein(a.param, b.param), *
FROM (
SELECT 5 fields
FROM table t,
JOIN x,
JOIN y,
GROUP BY 1, 2, 3
) a,
FROM (
SELECT 5 fields
FROM table t,
JOIN x,
JOIN y,
GROUP BY 1, 2, 3
) b,
有没有办法不复制内部SELECT
?
答案 0 :(得分:0)
解决方案非常简单,感谢@Nikarus关于WITH表达式的建议:
WITH subtable AS (
SELECT 5 fields
FROM table t,
JOIN x,
JOIN y,
GROUP BY 1, 2, 3
)
SELECT levenshtein(a.param, b.param), *
FROM subtable a, subtable b