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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:57:40+00:00 2026-05-16T06:57:40+00:00

I have a work plan in DB as follows. For instance, the first row

  • 0

I have a work plan in DB as follows. For instance, the first row means that Team A has 10 hours’ work to do in June (SP1006).

Team Sprint  WorkHours
A    1006    10
A    1007    20
A    1008    30
A    1009    40
B    1008    50
B    1009    60
B    1010    70

I want to derive it into the following form to show: at the end of each month, how many hours are left to be done, according to the work plan. As you see, the fields of the derived table depend on the original datatable too.

Team    SP1005  SP1006  SP1007  SP1008  SP1009  SP1010
A       100     90      70      40      0       0
B       180     180     180     130     70      0

I’m trying to do this on SQL Server 2000. This is really hard for me. Can someone give some help? Thanks a lot!

Edit: Or you can ignore the row-to-column transformation part, (which I know how to do,) just concentrate on the accumulation part.

  • 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-16T06:57:41+00:00Added an answer on May 16, 2026 at 6:57 am

    For the accumulation part use a cursor. Unless the result set is very small (maybe <100 rows to process) when you can get away with a triangular join like.

    SELECT t1.Team, t1.Sprint,g.wh-SUM(t2.WorkHours)
     FROM tbl t1 JOIN tbl t2 ON t1.Team = t2.Team AND t2.Sprint <= t1.Sprint
     JOIN 
       (SELECT SUM(WorkHours) AS wh, Team  FROM tbl GROUP BY Team) g ON t1.Team=g.Team
     GROUP BY t1.Team, t1.Sprint,g.wh
    

    But as the number of rows grows the amount of work required by the triangular join grows exponentially.

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

Sidebar

Related Questions

I am looking to have a portable debug class since i plan to work
I have a work page that shows all projects. I am using a taxonomy
I have to work with a string standing for a keystroke (for instance A,
I have to work with a queryset, that is already filtered, eg. qs =
I have a website that is totally in French. I plan to have an
I have an iPad application that has a base image UIImageView (in this case
I have a photo viewer page that I need to make work with varying
I have a client-server architecture where the server has its clients do work in
I have to work with this library that deals with a standard for biodiversity.
I have this plan to create my own portfolio website and it has been

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.