1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
with Orders_CTE ([ORDER], [SOrder], [Sales order desc], Name)
as
(
select distinct [ORDER], [SOrder], [Sales order desc], Name
from ZMD4C z4 inner join y_ko4_27000037 y on z4.[ORDER] = y.[Sales doc]
)
select [Plant], [MRP Area], [Purch. Group], [REQ No], [Material], [Short Text] as 'Iman Description',
[Unit of Measure], [Quantity], [Acct Assgt Cat.] as 'Account assignment',
[Item Category], [Cross-Plant Mat Stat], [Sales order desc] as 'Name of responsible Project controler',
[Requisn Date], [Release Date],[Delivery Date], [Fixed Vendor], [Exception codes],
[Valuation Price], [Name] as 'Sold to Party',
[Plant-Spec Mat Stat] as 'Plant-Spec Mat Stat (never purchased? Req)',
[Pl. Deliv. Time], ["Fixed" Ind.], [Material Group], [PROJECT] as 'PROJECT (TA or multi)',
[ORDER] as 'DEMAND', [SRM Bid], [SRM Contract], [SRM Vendor], [SRM Vendor Name], [SRM PO], [SRM PO Status]
from
( select z.id, [Plant], [MRP Area], [Purch. Group], [REQ No], [Material], [Short Text],
[Unit of Measure], [Quantity], [Acct Assgt Cat.],
[Item Category], [Cross-Plant Mat Stat], [Sales order desc],
[Requisn Date], [Release Date],[Delivery Date], [Fixed Vendor], [Exception codes],
[Valuation Price], [Name],
[Plant-Spec Mat Stat],
[Pl. Deliv. Time], ["Fixed" Ind.], [Material Group], [PROJECT],
[ORDER], [SRM Bid], [SRM Contract], [SRM Vendor], [SRM Vendor Name], [SRM PO], [SRM PO Status],
ROW_NUMBER() OVER(PARTITION BY [REQ No] ORDER BY [ORDER] ASC) [RowNumber]
from ZREQS z left outer join Orders_CTE d on z.[REQ No] = d.SOrder ) t
where RowNumber = 1; |
Partager