I would like to create a view from my table called InvQty
Please at the attached examples. the top column needs to sum the data by year and month.
Thank You
I would like to create a view from my table called InvQty
Please at the attached examples. the top column needs to sum the data by year and month.
Thank You
Please post all example data in the form of create table and insert statements.
warehouse is always 02
CREATE TABLE [dbo].[MForecast](
[StockCode] varchar NOT NULL,
[ForecastDate] NOT NULL,
[ForecastWh] [varchar] NOT NULL,
[Line] [decimal](3, 0) NOT NULL,
[Qty] [decimal](18, 6) NOT NULL,
[TimeStamp] [timestamp] NULL,
CONSTRAINT [MForecastKey] PRIMARY KEY CLUSTERED
Below Is A Query I Am Using for The Same Purpose
I Have Three Tables (Invoice, Invoice Details, Stock)
SELECT CAST(MONTH(Invoices.INDATE) AS nvarchar) + '/' + CAST(YEAR(Invoices.INDATE) AS nvarchar) AS Date, Invoices_Details.TNITEM, STOCK.STDESC,
SUM(Invoices_Details.TNQTYI) AS QTY
FROM Invoices INNER JOIN
Invoices_Details ON Invoices.INTRNS = Invoices_Details.TNTRNS INNER JOIN
STOCK ON Invoices_Details.TNITEM = STOCK.STCODE
GROUP BY Invoices_Details.TNITEM, STOCK.STDESC, CAST(MONTH(Invoices.INDATE) AS nvarchar) + N'/' + CAST(YEAR(Invoices.INDATE) AS nvarchar)
hope This Would help you