Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rollup and group by

Status
Not open for further replies.

segmentfault

Programmer
Apr 1, 2004
3
US
i have a table that contain the following
visit days total_days
1 2
2 3
3 1
4 2

what i want to do is sum up the days so that the output looks like this

visit days total_days
1 2 2
2 3 5
3 1 8
4 2 10

can i do this with rollup and group by? i tried but i couldn't do it. please help.
 
Why would you want to store this value? What if you made a change to Visit #2's Day's value? You would then have to rerun this update. This is called a calculated field and usually should not be stored in the database.

Terry
**************************
* General Disclaimer - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
the total_days column will not be store in the database. this column will just be generated when the sql query is run.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top