ABAP选择带有count>的字段1

时间:2018-03-22 10:25:55

标签: sql sap abap

有没有办法从BSID中选择一些字段,其中BUKRS-KUNNR-DMBTR的组合大于1.我认为下面的选择将起作用,但它没有。

SELECT bukrs kunnr dmbtr COUNT(*)
      INTO TABLE git_double
    FROM bsid
    WHERE bukrs = '1000' AND
          blart = 'WP'   AND
          budat IN s_budat AND
          gjahr IN s_gjahr AND
          count(*) > 1
    GROUP BY bukrs kunnr dmbtr.

有没有办法在1次选择中这样做?
感谢

1 个答案:

答案 0 :(得分:4)

aggregate functions上的HAVING选项可以在host variables子句中完成

COUNT

有关信息,请参阅ABAP 7.40 SP05,您也可以使用enter image description here编写:

  SELECT bukrs kunnr dmbtr COUNT(*)
    INTO TABLE git_double
      FROM bsid
      WHERE bukrs = '1000' AND
            blart = 'WP'   AND
            budat IN s_budat AND
            gjahr IN s_gjahr
      GROUP BY bukrs kunnr dmbtr
      HAVING COUNT(*) > 1.        " <==== HAVING after GROUP BY