Hi,

I was wondering if any one could help me with something (for some reason) I'm finding difficult to achieve.

I'm querying data with joins that I've created and would be something along the lines of:

PersonID, OrderCount, SalesTotal, WeekNo, Year

The Tsql being:

Select PersonID, PersonCatagory, count(tableB.OrderNo) as OrderCount, Sum(tableB.Revenue) as SalesTotal, Week(orderdate), Year(orderdate) from tableA
Right Join tableB on personID = clientID
Where PersonCategory = 'GG'
Group By PersonID
Having Week = '10' and Year = '2017'

The above works fine (sorry if anything is slightly incorrect there, I'm not in front of my computer)

However, I'm looking at adding in the sum of 2016-01-01 to current year and week number. I tried a sub query at the end but this didn't seem to work.

Does anyone know how I could achieve this so the same grouping rules apply but the output would be

PersonID, OrderCount, SalesTotalLastWeek, SalesTotalThisYear, WeekNo, Year

Many thanks!