2

我需要从 likp 中选择 vbeln,并且我必须只选择在 vbuk 中标记为“C”的 vbeln。并且从那个 likp-vbeln(delivery) 中,我必须在 vekp 中搜索/选择其承运人,然后在搜索承运人之后,我必须从另一个表中搜索/选择其船型。我有 7 个字段的表,在下面的代码中,我选择了一些交付,但我不知道如何在 vbuk 表中添加条件,因为我不需要从 vbuk 中选择。谢谢。代码如下:

SELECT likp~vbeln
     tab~shiptype
     vekp~carrier
     vekp~service
     COUNT( DISTINCT vekp~shipment )
     SUM( vekp~packagecount )
     SUM( vekp~rate ) FROM vekp
  INNER JOIN tab
  ON tab~carrier = vekp~carrier INNER JOIN likp
  ON vekp~delivery = likp~vbeln INTO itab
  WHERE likp~erdat IN so_date AND
        vekp~delivery = likp~vbeln AND
        vekp~carrier = tab~code
        GROUP BY vbeln shiptype carrier service.
4

1 回答 1

1

您无需从表中进行选择即可加入,只需将 VBUK 添加到您的加入中即可。

我注意到您没有包含使用字段列表时需要的 INTO 子句。

就像是:

SELECT likp~vbeln
 tab~shiptype
 vekp~carrier
 vekp~service
 COUNT( DISTINCT vekp~shipment )
 SUM( vekp~packagecount )
 SUM( vekp~rate ) 
INTO (field1, fied2, etc)                    "<=== Change1
FROM vekp
INNER JOIN tab
  ON tab~carrier = vekp~carrier INNER JOIN likp
  ON vekp~delivery = likp~vbeln INTO itab
INNER JOIN VBUK                              "<=== Change2
  ON likp~vbeln = vbuk~vbeln
WHERE likp~erdat IN so_date AND
    vekp~delivery = likp~vbeln AND
    vekp~carrier = tab~code AND
    vbuk~fieldtocheck = 'C'                  "<=== Change3
GROUP BY vbeln shiptype carrier service.
于 2013-04-06T22:04:22.880 回答