How to sum consecutive in number of day
-
Hi All. I have a table in Microsoft SQL Database like that. date,UserID,number_of_product, number_of_sale Every day User sale number of product. Now I Want to count consecutive for each user, each product, and each day the total number of sale in number of day (for example 7 days) Thanks
-
Hi All. I have a table in Microsoft SQL Database like that. date,UserID,number_of_product, number_of_sale Every day User sale number of product. Now I Want to count consecutive for each user, each product, and each day the total number of sale in number of day (for example 7 days) Thanks
See SQL COUNT() Function[^] and SQL BETWEEN Operator[^].
-
See SQL COUNT() Function[^] and SQL BETWEEN Operator[^].
The Data like that of course there is more ID ID1,14/04/2016, 5 ID1,13/04/2016, 2 ID1,11/04/2016, 1 ID1,10/04/2016, 4 ID1,08/04/2016, 7 So the Result like that. ID1, 14/04, 19 (19=5+2+1+4+7) ID1, 13/04, 14 (2+1+4+7) ID1, 11/04, 12 (1+4+7) ID1, 10/04, 11 (4+7) ID1, 08/04, 7
-
The Data like that of course there is more ID ID1,14/04/2016, 5 ID1,13/04/2016, 2 ID1,11/04/2016, 1 ID1,10/04/2016, 4 ID1,08/04/2016, 7 So the Result like that. ID1, 14/04, 19 (19=5+2+1+4+7) ID1, 13/04, 14 (2+1+4+7) ID1, 11/04, 12 (1+4+7) ID1, 10/04, 11 (4+7) ID1, 08/04, 7
-
Hi All. I have a table in Microsoft SQL Database like that. date,UserID,number_of_product, number_of_sale Every day User sale number of product. Now I Want to count consecutive for each user, each product, and each day the total number of sale in number of day (for example 7 days) Thanks
Familiarise yourself with aggregate functions in SQL. GroupBy etc. If you learn them , what you are trying to do is simple for you.