我怎样才能得到:



  pn     | min max
  ------ | ------
  ABC123 | 0,0
  ABC123 | 1,1
  ABC123 | 1,1
  ABC123 | 1,1


至:

  pn     | min max
  ------ | -------
  ABC123 | 3,3



Oracle数据库11g
PL / SQL 11.2.4.0


这就是我现在所拥有的:

SELECT
   PN_INVENTORY_LEVEL.PN,
   PN_INVENTORY_LEVEL.MAXIMUM_STOCK || ',' || PN_INVENTORY_LEVEL.MINIMUM_STOCK AS MIN_MAX
FROM
   PN_INVENTORY_LEVEL
WHERE ("PN_INVENTORY_LEVEL"."PN" = :PN)

最佳答案

尝试使用

 SELECT
               PN_INVENTORY_LEVEL.PN,
               Sum(PN_INVENTORY_LEVEL.MAXIMUM_STOCK) || ',' || sum(PN_INVENTORY_LEVEL.MINIMUM_STOCK) AS MIN_MAX
    FROM
               PN_INVENTORY_LEVEL
    WHERE ("PN_INVENTORY_LEVEL"."PN" = :PN)
group by PN_INVENTORY_LEVEL.PN

关于sql - 你如何求和和组合一个字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39392673/

10-09 01:09