16,552
社区成员
发帖
与我相关
我的任务
分享
queryCondition = " ProductNo like '" & TxtProductNo.Text.Trim & "%' AND"
sql = " ClassNo in (Select ClassNo from V_FindProducts where ParentNo='" & str_CNO(1).Trim("]") & "') and " & queryCondition
str_QureySQL = "DECLARE @sql VARCHAR(8000)"
str_QureySQL = str_QureySQL & " SET @sql='SELECT barcode,ProductNo,Named,Standard,Unit'"
str_QureySQL = str_QureySQL & " SELECT @sql=@sql+',['+storage+']=MAX(CASE storage WHEN '''+storage+''' THEN StockAmt ELSE 0 END)'"
str_QureySQL = str_QureySQL & " + ',['+storage+']=MAX(CASE storage WHEN '''+storage+''' THEN StockCash ELSE 0 END)' "
str_QureySQL = str_QureySQL & " + ',['+storage+']=MAX(CASE storage WHEN '''+storage+''' THEN CostPrice ELSE 0 END)' "
str_QureySQL = str_QureySQL & " FROM V_FindProducts GROUP BY storage Having" & sql & " "
str_QureySQL = str_QureySQL & " EXEC(@sql+' FROM V_FindProducts GROUP BY barcode,ProductNo,Named,Standard,Unit Having" & sql & " ')"