亲爱的朋友我写了以下查询,我得到的结果也像图片一样。
Select
(case when croptype_code < 13 then 'Pedi' else 'Paudha' end) pl_rpflag,
nvl(sum(gh_area),0) as Area
from w_cane_survey_2013
where unit_code = '03' and gh_vill = '9991' and gh_grow= '1'
group by croptype_code;
row1和row3都有 Paudha ,但其区域是单独显示的。现在我想要添加这样的值。表示 Paudha 的所有值都应该在一行中,并且所有 Pedi 值都在一行中。
答案 0 :(得分:0)
SELECT M.pl_rpflag, Sum(M.Area) FROM
(
SELECT (CASE WHEN croptype_code < 13 THEN 'Pedi' ELSE 'Paudha' end) AS pl_rpflag,
nvl(sum(gh_area),0) AS Area
FROM w_cane_survey_2013
WHERE unit_code = '03'
AND gh_vill = '9991'
AND gh_grow= '1'
) AS M
GROUP BY M.pl_rpflag