Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

Selecting a date range month over month (reporting related question)..newb question :(

$
0
0
So basically, I'd like to get a count of a few different fields within a table, BUT ONLY for a specific date range month over month. In other words, I want the 1st of every month through the 23rd of every month.SELECTDATE_TRUNC('month', n.campaign_date) <--- i want the date trunc to reflect ONLY the 1st - 23rd of every month. I then want to get the count of various metrics in the same table assocaited with the 1-23rd of every month. I'm basically doing reporting month vs month to gauge effectiveness.^^ This ideally would look like: Date Field Metric Metric2 Metric 3 2015-01-01 - 2015-01-23 45 523 234232015-02-01 - 2015-02-23 45 523 234232015-03-01 - 2015-03-23 45 523 23423,COUNT(numberofresponders),COUNT(othermetric),COUNT(othermetric2)FROMtableWHEREcampaign_date >= '2015-01-01

Viewing all articles
Browse latest Browse all 6525

Trending Articles