AnsweredAssumed Answered

ExecuteSQL With WHERE Clause Addition

Question asked by laguna92651 on Dec 28, 2018
Latest reply on Dec 29, 2018 by laguna92651

I'm using the following ExecuteSQL statement, it returns the expected answer. When I add a third condition, _Status, to the WHERE clause I do not get the correct answer. I get the same answer as before adding the _Status condition. The $status variable does not change and is set in the script.

Let ([

_Data  = _FIELDREF_getField  ( T35_Quote_Product_Join_Table::ExtendedPrice_calc ; True ) ;

_Type = _FIELDREF_getField   ( T35_Quote_Product_Join_Table::Product_lookup ; True ) ;

_Year = _FIELDREF_getField   ( T35_Quote_Product_Join_Table::Year ; True ) ;

 

_Table = _FIELDREF_getTO ( T35_Quote_Product_Join_Table::ID_EST_LINE ; True ) ;

 

_Query = "SELECT Sum(" & _Data &  ") FROM " & _Table &" WHERE " & _Year  & " = ? AND " & _Type & " = ? "

];

ExecuteSQL(_Query ; "";"";  $Year ; $type )

)

 

When I add _Status to the WHERE clause I still get the same answer as I got without the additional condition.

Let ([

_Data  = _FIELDREF_getField  ( T35_Quote_Product_Join_Table::ExtendedPrice_calc ; True ) ;

_Type = _FIELDREF_getField   ( T35_Quote_Product_Join_Table::Product_lookup ; True ) ;

_Year = _FIELDREF_getField   ( T35_Quote_Product_Join_Table::Year ; True ) ;

_Status = _FIELDREF_getField ( T35_Quote_Product_Join_Table::Status_Quote_Lookup ; True ) ;

 

_Table = _FIELDREF_getTO ( T35_Quote_Product_Join_Table::ID_EST_LINE ; True ) ;

 

_Query = "SELECT Sum(" & _Data &  ") FROM " & _Table &" WHERE " & _Year  & " = ? AND " & _Type & " = ? AND " & _Status & " = ?"

];

ExecuteSQL(_Query ; "";"";  $Year ; $type ; $status)

)

Outcomes