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 7774073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:17:13+00:00 2026-06-01T17:17:13+00:00

I would appreciate some help on this. I have this table: RECHARGES ___________ DATE_TIME

  • 0

I would appreciate some help on this. I have this table:

RECHARGES
___________
DATE_TIME               CLIENT          RECHARGED_MONEY
2011-01-01 12:25:25.000 2,051307E+09    50000
2011-01-01 12:26:27.000 2,140614E+09    100000
2011-01-01 12:27:03.000 1,074146E+09    50000

…
I want to sum the recharged_money of each client and make groups of 5 days from the last to the first charge date.

So i pick the last date and sum all the recarged_money until 5 days before, and more 5 .. and so on. How can i accomplish that?

Ty in advanced,
J

  • 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-06-01T17:17:14+00:00Added an answer on June 1, 2026 at 5:17 pm

    Something like this should help, if I haven’t missed anything:

    WITH marked AS (
      SELECT
        DATE_TIME,
        RECHARGED_MONEY,
        dategroup = DATEDIFF(DAY, DATE_TIME, MAX(DATE_TIME) OVER ()) / 5
      FROM RECHARGES
    )
    SELECT
      DATE_TIME       = MAX(DATE_TIME),
      RECHARGED_MONEY = SUM(RECHARGED_MONEY)
    FROM marked
    GROUP BY
      dategroup
    ORDER BY
      DATE_TIME
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem finding references to this subject and would appreciate some help.
OK Ladies and Gents, I would really appreciate some help: This is my table:
I have run out of ideas on this issue and would appreciate some help
I would appreciate some help with something I working on and have not done
I'm fairly new to SQL Server and would really appreciate some help with this.
Wondering if anyone can help with this. I have a table with some fixed
I would appreciate some help with an UPDATE statement. I want to update tblOrderHead
I would appreciate some help on creating the proper SQL to retrieve only one
I'm pretty new to Python programming and would appreciate some help to a problem
I would really appreciate it if some of you could help optimize my tables,

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.