SQL изменить все элементы - PullRequest
0 голосов
/ 18 октября 2019

Как выбрать все элементы, которые начинаются с i вместо Items.ItemCode = '107669'

SELECT p.ProjectNr AS Production, 
       gbkmut.oms25 AS Description, 
       (CASE 
          WHEN SUM(gbkmut.aantal) < 0 AND gbkmut.transsubtype <> 'J' 
            THEN -SUM(gbkmut.aantal) 
          ELSE SUM(gbkmut.aantal) 
       END) AS Quantity, 
       gbkmut.warehouse AS Warehouse, 
       gbkmut.id AS RecordNum 
FROM PrProject p 
   JOIN gbkmut ON p.ProjectNr=gbkmut.project 
              AND gbkmut.bud_vers='MRP' AND gbkmut.transtype='B' 
              AND gbkmut.freefield1='P' 
             AND gbkmut.transsubtype IN ('A','B','J') 
   JOIN Items ON Items.ItemCode=gbkmut.artcode 
             AND Items.GLAccountDistribution=gbkmut.reknr   
WHERE p.Type='P' 
  AND Items.ItemCode = '107669'
  AND gbkmut.afldat >= {d '2019-01-01'} 
  AND gbkmut.afldat <= {d '2019-12-31'} 
GROUP BY p.ProjectNr, gbkmut.oms25, gbkmut.warehouse, gbkmut.afldat, gbkmut.transsubtype, gbkmut.id 
ORDER BY p.ProjectNR

1 Ответ

0 голосов
/ 18 октября 2019

не будет работать ...

SELECT p.ProjectNr AS Production, gbkmut.oms25 AS Description, (CASE WHEN SUM(gbkmut.aantal) < 0 AND gbkmut.transsubtype <> 'J' THEN -SUM(gbkmut.aantal) ELSE SUM(gbkmut.aantal) END) AS Quantity, gbkmut.warehouse AS Warehouse, gbkmut.id AS RecordNum FROM PrProject p JOIN gbkmut ON p.ProjectNr=gbkmut.project AND gbkmut.bud_vers='MRP' AND gbkmut.transtype='B' AND gbkmut.freefield1='P' 
AND gbkmut.transsubtype IN ('A','B','J') JOIN Items ON Items.ItemCode=gbkmut.artcode AND Items.GLAccountDistribution=gbkmut.reknr   WHERE p.Type='P' **like Items.ItemCode = 'i%'**
 AND gbkmut.afldat >= {d '2019-01-01'} AND gbkmut.afldat <= {d '2019-12-31'} GROUP BY p.ProjectNr, gbkmut.oms25, gbkmut.warehouse, gbkmut.afldat, gbkmut.transsubtype, gbkmut.id ORDER BY p.ProjectNR
...