Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Select latest month inventory

$
0
0

Hi,

I am trying to select inventory value for the last month for each material. The following is the result set from my query and I want to select only the circled rows (inventory value from latest month). The query I am running is attached as well. Any assistance would be of great help. Thanks.

SELECT MBEW.MATERIAL_MATNR AS MBEW_MATNR,

MBEW.VALUATION_AREA_BWKEY MBEW_BWKEY,
MBEW.TOTAL_VALUE_SALK3 AS MBEW_SALK3,
MBEWH.YEAR_CURPERIOD_LFGJA MBEWH_LFGJA ,
MBEWH.CURRENT_PERIOD_LFMON MBEWH_LFMON,
MBEWH.TOTAL_VALUE_SALK3 AS MBEWH_SALK3
FROM [Materials].[MBEW_MATERIAL_VALUATION] MBEW
LEFT OUTER JOIN [Materials].[MBEWH_MATERIAL_VALUATION_HISTORY] MBEWH ON
MBEW.[MATERIAL_MATNR]=MBEWH.MATERIAL_MATNR
AND MBEW.[VALUATION_AREA_BWKEY]=MBEWH.[VALUATION_AREA_BWKEY]
AND MBEW.[VALUATION_TYPE_BWTAR]=MBEWH.[VALUATION_TYPE_BWTAR]
WHERE MBEW.VALUATION_CLASS_BKLAS=3030 AND 
MBEW.VALUATION_AREA_BWKEY ='1510'
AND MBEWH.TOTAL_VALUE_SALK3<>0.00
and MBEWH.YEAR_CURPERIOD_LFGJA=2013
ORDER BY MBEW_MATNR

Query Results


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>