我的表中包含以下列中的值:低,中,高和月。 我想得到以下每月最大值的结果。它将获取每月每列的最大值。
这是我的陈述
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
答案 0 :(得分: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;