Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention. Check out this how-to article for more information.
SELECT DISTINCT sqcl.SalesQuoteNumber , sqcl.ItemNumber , ( SELECT DISTINCT s.SalesQuoteNumber FROM cost.vStd_SalesQuoteCostLine s WHERE s.CustomerNumber_BillTo = sqcl.CustomerNumber_BillTo AND s.ItemNumber = sqcl.ItemNumber AND s.DocumentDate = ( SELECT MAX(s2.DocumentDate) FROM cost.vStd_SalesQuoteCostLine s2 WHERE s2.CustomerNumber_BillTo = sqcl.CustomerNumber_BillTo AND s2.ItemNumber = sqcl.ItemNumber AND s2.DocumentDate < sqcl.DocumentDate ) ) AS PriorQuoteNumber FROM cost.vStd_SalesQuoteCostLine sqcl WHERE sqcl.SalesQuoteNumber = @SalesQuoteNumber
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.