Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7672011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:11:17+00:00 2026-05-31T16:11:17+00:00

I am doing a sql server report that shows running daily, monthly, and yearly

  • 0

I am doing a sql server report that shows running daily, monthly, and yearly totals at the bottom of the report.

I figured out how to do the daily report by taking the datediff of the “timestamp” field and a getdate() and returning rows that were = 0. That way I knew the difference in dates was 0 days and thus part of the daily total.

I am running into an issue as to a good way to do this with month and year. Here is the query I have for month calculation and it is giving me way more results than it should (I have another table which i’m using to double check my calculations. I should get about 300 as my total but the query below gives me about 7400 instead. Just a little off)

     SELECT     SUM(Rc0) AS Good, 
                      SUM(Rc0 + Rc1 + Rc2 + Rc3 + Rc4 + Rc5 + Rc6 + Rc7 + Rc8 + Rc9 + Rc10 + Rc11 + Rc12 + Rc13 + Rc14 + Rc15 + Rc16 + Rc17 + Rc18 + Rc19 + Rc20 + Rc21 + Rc22 + Rc23
                       + Rc24 + Rc25 + Rc26 + Rc27 + Rc28 + Rc29 + Rc30 + Rc31 + Rc32 + Rc33 + Rc34 + Rc35 + Rc36 + Rc37 + Rc38 + Rc39 + Rc40) AS Not_Good  
FROM         someTable WHERE     (MONTH(timestamp) = MONTH(GETDATE())) and (YEAR(timestamp) = YEAR(GETDATE()))

edit: alternate form of query that is giving me same result

SELECT     SUM(Rc0) AS Good, 
                      SUM(Rc0 + Rc1 + Rc2 + Rc3 + Rc4 + Rc5 + Rc6 + Rc7 + Rc8 + Rc9 + Rc10 + Rc11 + Rc12 + Rc13 + Rc14 + Rc15 + Rc16 + Rc17 + Rc18 + Rc19 + Rc20 + Rc21 + Rc22 + Rc23
                       + Rc24 + Rc25 + Rc26 + Rc27 + Rc28 + Rc29 + Rc30 + Rc31 + Rc32 + Rc33 + Rc34 + Rc35 + Rc36 + Rc37 + Rc38 + Rc39 + Rc40) AS Not_Good
FROM         someTable
WHERE     convert(varchar(7), timestamp, 126) = convert(varchar(7), getdate(), 126)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:11:18+00:00Added an answer on May 31, 2026 at 4:11 pm

    –As a generic sort of grouping including most spans…..

    SELECT
    ‘Year’ = DATEPART(Yy, rowdate),
    ‘Month’ = DATEPART(Mm, rowdate),
    ‘Week’ = DATEPART(wk, rowdate),
    ‘Total’ = sum(yournumericfield)

    FROM sometable

    GROUP BY
    DATEPART(Yy, rowdate),
    DATEPART(Mm, rowdate),
    DATEPART(wk, rowdate)

    ORDER BY
    DATEPART(Yy, rowdate),
    DATEPART(Mm, rowdate),
    DATEPART(wk, rowdate)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any tool that will inspect either asp.net or sql server and report
I'm just wondering if there's a better way of doing this in SQL Server
Does SQL Server 2005 maintain built-in, queryable, row-level last-modified timestamp metadata? I'm doing some
I'm doing a bulk insert of a CSV file into SQL Server 2005, using
I’m trying to bulk insert data to SQL server express database. When doing bcp
I'm working on a rather complex report in Sql Server Reporting Services. My SP
in Sql Server Reporting Services Report is it possible to define a MDX query
i have built a reporting services report off SQL server 2005 and am having
So I am doing a SQL Import via Sql Server Import and Export Wizard
I'm tasked with doing a SQL Server 2000 to 2005 migration. I will be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.