Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

SQL adding productid

I have the following problem.

First off all I am a new guy and trying to learn SQL. The problem is that I want to add de itemcode to this code, but this is not possible. Can someone help me??

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 BETWEEN 'U10-0100-10' AND 'U10-0200-10'
    AND gbkmut.afldat >= {d '2018-01-01'} AND gbkmut.afldat <= {d '2018-12-31'}
GROUP BY 
    p.projectnr,
    gbkmut.oms25, gbkmut.warehouse,
    gbkmut.afldat, gbkmut.transsubtype,
    gbkmut.id
ORDER BY 
    p.projectnr

This will return:

enter image description here

I want to add the itecomcode in the first column.

Thanks.

Comments