• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 568
  • Last Modified:

Count the records per week

Hi guys,

Can someone please give the query syntax for counting the records of Field 1 per week (Field 2 with daily dates).
The week starts Monday.
Thank you
0
marian68
Asked:
marian68
  • 2
2 Solutions
 
Dale FyeCommented:
In Access, this might look like:

SELECT Year([Field2]) as TransYear, DatePart("ww", [Field2]) as TransWeek, Count(*) as WeekCount
FROM yourTable
GROUP BY Year([Field2]) as TransYear, DatePart("ww", [Field2]) as TransWeek
0
 
Jared_SCommented:
select
datepart(year,field2) as [year],datepart(week,field2) as [week], count(field1) as [Count]
from table
group by datepart(week,field2),datepart(year,field2)
order by datepart(year,field2), datepart(week,field2)
0
 
Jared_SCommented:
The access syntax that fyed posted will work in MS SQL too... no need for my re-post.
0
 
marian68Author Commented:
Thank you guys,
Yes the first query worked.
Thank you both
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now