我试图让两列,frequency
而frequency - min(frequency)
但是我看到的是第二列为零.什么可能是错的?
SELECT frequency, frequency - min(frequency) FROM words GROUP BY id ORDER BY frequency;
您的查询组由频率的唯一值组成.在每个这样的组中,最小频率只是频率本身,因此0
在减去两者时总会得到.相反,您可以使用以下窗口版本min
:
SELECT frequency, frequency - MIN(frequency) OVER() AS diff FROM words ORDER BY frequency