I have this DDL table:
CREATE TABLE [dbo].[Audit] ( [AuditId] INT IDENTITY (1, 1) NOT NULL, [Entity] INT NOT NULL, [Action] INT NOT NULL, [Id] UNIQUEIDENTIFIER NULL, CONSTRAINT [PK_Audit] PRIMARY KEY CLUSTERED ([AuditId] ASC) );
Update . I added the missing SQL here. Sorry, that
What I did was create a SQL report using this SQL, which will show me how much activity there was every day:
select [col1] = CONVERT(VARCHAR(10), DATEADD(HOUR, 8, a.date), 101) , [Col2] = convert(varchar, count(*)) from Audit a group by CONVERT(VARCHAR(10), DATEADD(HOUR, 8, a.date), 101) order by CONVERT(VARCHAR(10), DATEADD(HOUR, 8, a.date), 101) desc
The result is as follows:
col1 Col2 03/05/2017 1 03/04/2017 20 03/03/2017 10 03/02/2017 5 03/01/2017 10
Now I need to make a SQL selection that shows me the cumulative value, not the score. So I need SQL that could create a report that shows this
col1 Col2 03/05/2017 46 03/04/2017 45 03/03/2017 25 03/02/2017 15 03/01/2017 10
Does anyone know how I can modify my SQL to create this type of report?
Please note that I'm really looking for one command solution, because it is executed from the .net structure, and if there are several commands in the solution, I think I will need to figure out how to do this in the stored procedure.