troubleshooting Question

t-sql RUNNING TOTALS QUERY

Avatar of innocent1973
innocent1973 asked on
Microsoft SQL Server 2008
8 Comments1 Solution506 ViewsLast Modified:
Hello Experts,

I have a db table named InventoryLookup. I store inventory transaction summaries in this table.

CREATE TABLE [dbo].[InventoryFact](
        [StyleCode] [varchar](23) NULL,
        [WarehouseID] [char](4) NULL,
        [DateID] [smalldatetime] NULL,
        [Quantity] [int] NULL
) ON [PRIMARY]

GO

INSERT INTO InventoryFact VALUES ('RW900505002493','1001','18/09/2009',23)
INSERT INTO InventoryFact VALUES ('RW900505002493','1001','19/09/2009',-1)
INSERT INTO InventoryFact VALUES ('RW900505002493','1001','22/09/2009',-1)
INSERT INTO InventoryFact VALUES ('RW900505002493','1001','29/09/2009',-1)

How can I apply a running total method to this table?
I mean my desired resultset should be like below:

'RW900505002493' 1001 18/09/2009 23
'RW900505002493' 1001 19/09/2009 22
'RW900505002493' 1001 22/09/2009 21
'RW900505002493' 1001 29/09/2009 20
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros