cancel
Showing results for 
Search instead for 
Did you mean: 

Query help

former_member699869
Participant
0 Kudos
218

Hello Experts,

Please look at the following query and suggest changes.

Requested format:

Item# | ATP until WH Arrival Date | WH Arrival Date | ATP until next Arrival Date | Next WH Arrival Date

SELECT T1.[ItemCode] //Item#


,(SELECT SUM(M0.[OnHand]) FROM OITW M0 WHERE M0.[ItemCode] = T0.[ItemCode] and  M0.[WhsCode] IN('21') - SELECT(SUM(T2.[Quantity]) from ORDR T2 where T2.[DocDueDate] <= T0.[U_WhsArrivalDate])) AS 'ATP until WH Arrival date' // Instock - sum(Open So where duedate <= date1 (T0.[U_WhsArrivalDate])


,T0.[U_WhsArrivalDate] AS 'WH Arrival Date' //date1


,(SELECT SUM(M0.[OnHand]) FROM OITW M0 WHERE M0.[ItemCode] = T0.[ItemCode] and M0.[WhsCode] IN('21') - SELECT(SUM(T2.[Quantity]) FROM ORDR T2 WHERE T2.[DocDueDate] <= MIN(T0.[U_WhsArrivalDate])) + SELECT SUM(T0.[Quantity]*T0.[Price]) FROM POR1 T0 INNER JOIN OITM T1 ON T0.ItemCode = T4.ItemCode INNER JOIN OPOR A2 ON T0.[DocEntry] = A2.[DocEntry] WHERE T1.[ItmsGrpCod] = T4.[ItmsGrpCod] and A2.[CANCELED] ='N' and A2.[DocStatus] ='O' and A0.[LineStatus] ='O' and A0.[WhsCode] in ('21') AND T0.[U_WhsArrivalDate] < MIN(T0.[U_WhsArrivalDate]) AND A0.[U_Container])<> '' AS 'ATP until next Arrival Date'


,CASE MIN(T0.[U_WhsArrivalDate]) WHEN '' THEN GETDATE()+60 ELSE NextWHArrivalDate END AS 'NextWHArrivalDate'


FROM POR1 T0 INNER JOIN OITM T1 ON T0.[ItemCode] = T1.[ItemCode], ORDR T2 INNER JOIN RDR1 T3 ON T2.[DocEntry] = T3.[DocEntry] INNER JOIN OITB T4 ON T1.[ItmsGrpCod] = T4.[ItmsGrpCod]
<br>
former_member699869
Participant
0 Kudos

johan.hakkesteegt , Can you suggest changes to this query?

former_member699869
Participant
0 Kudos

Hello, I am still looking for suggestions to this query!

former_member699869
Participant
0 Kudos

zal.parchem2 kennedy.t mike.taylor3 johan.hakkesteegt

former_member699869
Participant
0 Kudos

unnikrishnan.balan

Johan_Hakkesteegt
Active Contributor
0 Kudos

Hi,

Your question is too vague. Please let us know what is wrong with your query. Do you get an error, or does it not return the expected result? If the latter, is the result wrong , or is expected data missing from the result?

Regards,

Johan

former_member699869
Participant
0 Kudos

johan.hakkesteegt ,

I get an error and facing issues troubleshooting the errors

Johan_Hakkesteegt
Active Contributor
0 Kudos

Ok, what is the error?

former_member699869
Participant
0 Kudos

Syntax errors!

Johan_Hakkesteegt
Active Contributor
0 Kudos

Could you please be a little more specific?

Please copy-paste your query into MS SQL Server Management Studio, and run it. You will get a list of errors if there are any. Let us know what the errors are, or better yet, try to fix them one by one, and run the query again after each fix.

former_member699869
Participant
0 Kudos

johan.hakkesteegt , Unfortunately, we don't have SSMS at our company. I am only able to write queries on the Query Generator.

former_member699869
Participant
0 Kudos

unnikrishnan.balan

Accepted Solutions (0)

Answers (2)

Answers (2)

wojciech_wozniak
Participant
0 Kudos

"Select" in "Select" don't work in the query manager

former_member699869
Participant
0 Kudos

Please refer to the attachment