I have this view with the year to date sales values for each stock item sold: -
SELECT Year, [Stock Code], SUM(SalesValue) AS TotVal
GROUP BY Year, [Stock Code]
HAVING (Year = YEAR(GETDATE()))
I want to create a SQL job to populate a table overnight e.g. tbl_Inventory_Category
I need to add StockCode and Category to the table, StockCode comes from the view. 'Category' is calculated thus:
• A= Products that make up 65% year to date sales.
• B= Next 20%
• C= Next 10%
• D= Next 5%
Does anyone know how to achieve this?