-1

我有一个表格,其中包含以下列中的值:低、中、高和月份。我想得到以下结果每月的最大值。它将获取每月每列中的最大值。

这是我的声明

SELECT MAX(low) as Low,MAX(medium) as Medium,MAX(high) as High,month as mth FROM tablename WHERE month > 0;

期望的结果是

month 1: Low 2 Medium 3 High 4

month 2: Low 4 Medium 2 High 5

month 3: Low 6 Medium 3 High 6

4

1 回答 1

1
SELECT MAX(low) as Low,MAX(medium) as Medium,MAX(high) as High,month as mth 
FROM tablename 
WHERE month > 0
GROUP BY month
ORDER BY month;
于 2013-05-06T15:04:01.717 回答