0

亲爱的朋友,我写了以下查询,我也得到了如图所示的结果。

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;

查询结果

第 1 行和第 3 行都有Paudha,但它的区域是分开显示的。现在我希望应该添加这样的值。意味着Paudha的所有值都应该在一行中,所有Pedi值都应该在一行中。

4

1 回答 1

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
于 2013-10-07T16:00:20.940 回答