Add in another column that sum of fields in same table

  • Hi,

    Name Marks

    Ashok 20

    Kamal 30

    Thiru 40

    This is my table. I need a output like this

    Name Marks Total

    Ashok 20 20

    Kamal 30 50

    Thiru 40 90

    U see the output table. In column Marks i added one by one to Total.First row is default.

    LIke 20,20+30,20+30+40 likewise i need to add in Total column

    What is the sql query for this one?

  • this is known as a "running totals" problem. running totals require a defined ORDER BY...wkether it is a PK, or alphabetically, or whatever...your example so far does not meet the requirement.

    take a look at this article about running totals[/url]. If you can post a true CREATE TABLE definition along with the INSERT INTO sample data, we could help a lot better.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply