1
Could someone please let me know why you made that mistake?
"Msg 8155, Level 16, State 2, Line 26 No column name was specified for column 1 of 'A'. Msg 8155, Level 16, State 2, Line 42 No column name was specified for column 1 of 'B'."
Follow the query and part of the error :
OUTER APPLY (SELECT CONCAT(TT.NUMSERI,TT.PRODUTO ,MAX(TT.DATA))
FROM TLX_INVENTORY_TRANS_HIST AS TT WITH (NOLOCK)
WHERE TT.PRODUTO = FN.PRODUTO AND TT.NUMSERI = FN.NUMSERI
GROUP BY TT.NUMSERI,TT.PRODUTO,TT.DATA)AS A
OUTER APPLY (SELECT CONCAT(TT.NUMSERI,TT.PRODUTO ,MIN(TT.DATA))
FROM TLX_INVENTORY_TRANS_HIST AS TT WITH (NOLOCK)
WHERE TT.PRODUTO = FN.PRODUTO AND TT.NUMSERI = FN.NUMSERI
GROUP BY TT.NUMSERI,TT.PRODUTO,TT.DATA)AS B
OUTER APPLY?! Got the topic’s answer https://answall.com/questions/273763/optimiza%C3%A7%C3%a3o-de-query-sql-server ?
– José Diz
Yes.. but where in that stretch? that Outer apply are two subquerys of a larger one
– Leonardo Palmieri
Yeah, take this OUTER APPLY and put LEFT JOIN. It gets simpler. See the answer in the linked topic.
– José Diz
LEFT JOIN in this case does not answer me, I took the test before making an Outer apply
– Leonardo Palmieri