此博客为原创博客,都是个人工作经历所得,转载请注明出处

SQL语句中使用除法

 

*取销售单价逻辑:
*从A305中根据KAPPL=V,KSCHL=ZP01, VKORG=P100,VTWEG=00,MATNR=“对应成品料号”,选择月份最后一天>= DATAB, 选择月份最后一天<= DATAB,取到A305-KNUMH;
*再从KONP中根据 KNUMH=A305-KNUMH,KAPPL=V,KSCHL=ZP01,获取销售原币KONP-KONWA,销售原币单价为KONP-KBETR/ KONP-KPEIN
SELECT A~MATNR,
       A~KUNNR,
       A~KNUMH,
       B~KBETR,
       B~KPEIN,
       CAST(  B~KBETR AS FLTP ) /  CAST( B~KPEIN AS FLTP ) AS DJ
  FROM A305 AS A
  JOIN KONP AS B
    ON A~KNUMH = B~KNUMH
*     FOR ALL ENTRIES IN @GT_MAT
 WHERE A~KAPPL = 'V'
   AND A~KSCHL = 'ZP01'
   AND A~VKORG = 'P100'
   AND A~VTWEG = '10'
*KUNNR
*     AND A~MATNR = @GT_MAT-MATNR
*KFRST
*   AND A~DATAB <= @SY-DATUM"有效从
*   AND A~DATBI >= @SY-DATUM"有效至
  INTO TABLE @DATA(LT_A305).

IF SY-SUBRC NE 0.

ENDIF.

 

 

 

 可以写除法,但是得到的结果不知道怎么用

 

posted @ 2021-06-23 16:20  Rainystuday  阅读(1340)  评论(0编辑  收藏  举报