Skip to Content
Former Member
Nov 12, 2007 at 04:09 PM

Exist now a solution for parameters and subselects in SQL query?


Hi all,

This is my query to obtain the quantity of wich item have in quotation ("Ofertado") with another information. This query crash.But if instead of putting [%0],[%1], i put '12/11/2007' , the query go well.This happens because T0.ShipDate belongs to the table that i use in the SUBSELECT to make a <b>where sentence</b> -


WHERE linestatus = 'O' AND itemcode = <b>T0.ItemCode</b>

T0 is RDR1 table.

SELECT T5.DocNum, T0.ObjType, T0.ShipDate, T5.CardCode, T5.CardName, T0.ItemCode, T0.U_referencia, T0.Dscription, T0.Quantity, T3.OnHand,

T3.IsCommited, T3.OnOrder, T0.LineStatus, T1.CardCode AS Expr1, T4.CardName AS Expr2, T3.WhsCode,

<b>(SELECT SUM(quantity)

FROM [dbo].[qut1]

WHERE linestatus = 'O' AND itemcode = T0.ItemCode) AS Ofertado</b> FROM <b> RDR1 T0</b> INNER JOIN

OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN

OITW T3 ON T0.ItemCode = T3.ItemCode FULL OUTER JOIN

OCRD T4 ON T1.CardCode = T4.CardCode INNER JOIN

ORDR T5 ON T0.DocEntry = T5.DocEntry

WHERE <b>(T0.ShipDate >= [%0])</b> AND <b>(T0.ShipDate <= [%1])</b> AND (T0.LineStatus = 'O') AND (T3.WhsCode = [%2])

Someone has any idea if exist a solution for this now?