Ask and you shall receive, looks like it creates a Proper SQL query with an actual whereClause and it uses CTE which is pretty awesome, so it can add the whereClause to the entire BAQ set… pretty SWANKY
with [SubQuery1] as
(select [PartBin].[PartNum] [PartBin_PartNum],[PartBin].[OnhandQty]-[PartBin].[AllocatedQty] [Calculated_Actual],[PartBin].[WarehouseCode] [PartBin_WarehouseCode],[PartBin].[BinNum] [PartBin_BinNum],[PartBin].[LotNum]
[PartBin_LotNum],[PartBin].[DimCode] [PartBin_DimCode],[Part_UD].[BaseName_c] [Part_BaseName_c],[Part_UD].[Calliper_RecID_c] [Part_Calliper_RecID_c],[Part_UD].[CoreDiameter_c]
[Part_CoreDiameter_c],[Part_UD].[CoreDiameterMetric_c] [Part_CoreDiameterMetric_c],[Part_UD].[Density_c] [Part_Density_c],[Part_UD].[Diameter_c] [Part_Diameter_c],[Part_UD].[DiameterMetric_c]
[Part_DiameterMetric_c],[Part_UD].[DimensionUoM_c] [Part_DimensionUoM_c],[Part_UD].[Format_c] [Part_Format_c],[Part_UD].[FormatDesc_c] [Part_FormatDesc_c],[Part_UD].[Grammage_c] [Part_Grammage_c],[Part_UD].[GrammageUoM_c] [Part_GrammageUoM_c],[Part_UD].[Length_c] [Part_Length_c],[Part_UD].[LengthMetric_c] [Part_LengthMetric_c],[Part_UD].[LinearFootFactor_c] [Part_LinearFootFactor_c],[Part_UD].[LinearFootUoM_c] [Part_LinearFootUoM_c],[Part_UD].[MillCode_c] [Part_MillCode_c],[Part_UD].[MillCodeDesc_c] [Part_MillCodeDesc_c],[Part_UD].[MWeight_c] [Part_MWeight_c],[Part_UD].[MWeightMetric_c] [Part_MWeightMetric_c],[Part_UD].[MWeightMetricUoM_c] [Part_MWeightMetricUoM_c],[Part_UD].[MWeightUoM_c] [Part_MWeightUoM_c],[Part_UD].[NetWeightAdder_c] [Part_NetWeightAdder_c],[Part_UD].[Packaging_c] [Part_Packaging_c],[Part_UD].[PackagingDesc_c] [Part_PackagingDesc_c],[Part_UD].[PoundFactor_c] [Part_PoundFactor_c],[Part_UD].[PoundUoM_c] [Part_PoundUoM_c],[Part_UD].[PrintingSideUp_c] [Part_PrintingSideUp_c],[Part_UD].[Product_RecID_c] [Part_Product_RecID_c],[Part_UD].[ProductMktDesc_c] [Part_ProductMktDesc_c],[Part_UD].[ProductName_c] [Part_ProductName_c],[Part_UD].[ProductNameEx_c] [Part_ProductNameEx_c],[Part_UD].[PurchasingFactor_c] [Part_PurchasingFactor_c],[Part_UD].[PurchasingFactor8_c] [Part_PurchasingFactor8_c],[Part_UD].[PurchasingUoM_c] [Part_PurchasingUoM_c],[Part_UD].[SalesGrade_c]
[Part_SalesGrade_c],[Part_UD].[SellingFactor_c] [Part_SellingFactor_c],[Part_UD].[SellingUoM_c] [Part_SellingUoM_c],[Part_UD].[SheetsPerPackingUnit_c] [Part_SheetsPerPackingUnit_c],[Part_UD].[SheetsPerPallet_c] [Part_SheetsPerPallet_c],[Part_UD].[SquareFootFactor_c] [Part_SquareFootFactor_c],[Part_UD].[SquareFootUoM_c] [Part_SquareFootUoM_c],[Part_UD].[StacksPerPallet_c] [Part_StacksPerPallet_c],[Part_UD].[Tabbed_c] [Part_Tabbed_c],[Part_UD].[ThicknessPoints_c] [Part_ThicknessPoints_c],[Part_UD].[Width_c] [Part_Width_c],[Part_UD].[WidthMetric_c] [Part_WidthMetric_c]
from ( [Erp].[PartBin] inner join @AvailCompLst [AvailCLst_PartBin] on [Erp].[PartBin].[Company] is null Or [Erp].[PartBin].[Company] = [AvailCLst_PartBin].[Company])
inner join ( [Erp].[Part] inner join [Erp].[Part_UD] on [Erp].[Part].[SysRowID] = [Erp].[Part_UD].[ForeignSysRowID]) on [Erp].[PartBin].[Company] = [Erp].[Part].[Company] And [Erp].[PartBin].[PartNum] = [Erp].[Part].[PartNum]
where [PartBin].[OnhandQty]-[PartBin].[AllocatedQty] > 0
)
select *
from [SubQuery1] [SubQuery1]
where (PartBin_PartNum = N'1/12/001/610/8011')