SQL Server Group data by week but show the start of the week -


i have query select customer data , want keep evolution of number of customers. in week 1 have 2 new customers number 2. in week 2 receive 3 new customers, number of customers 5.

i have following query this

select last_updated_week, sum( num_customers ) on ( order last_updated_week rows between unbounded preceding , current row ) "number of customers" (   select dateadd(dd,datediff(dd,0,registration_date),0) last_updated_week,          count(distinct customer_id) num_customers     customers_table   group dateadd(dd,datediff(dd,0,registration_date),0)) t 

but when run query, doesn't group data week. read datepart function, returns integer, need have actual date. can me?

just replace dd in dateadd , datediff functions week


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -