Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

How to find total row count on weekly basis

$
0
0

I have written a join query which works perfect and it give me total number of rows between two dates, however is there a way where i can modify my query so that i can see the result on weekly basis from January 2014 to may 2014

;WITH SourceData
as
(
    SELECT tablet.Approach.ApproachId
    ,StartDateTime
    ,QuestionId, Stage
    FROM Tablet.Approach
    JOIN tablet.DataCapture ON tablet.Approach.ApproachId = tablet.DataCapture.ApproachId
    WHERE QuestionId in (9,10)
    and Stage = 2
    and StartDateTime between '2014-01-01 00:00:00' and '2014-05-20 00:00:00'

)
,RecordCnt
AS
(
    SELECT COUNT(ApproachId) AS TotalInformationEffectContacts
    FROM SourceData
)
Select * from SourceData Cross join RecordCnt

order by StartDateTime asc


Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>