Sum

  • HI,

    I have table like the given below

    gradelosalhisal

    17001200

    212011400

    314012000

    420013000

    530019999

    so, i need the Total of that cols like given below

    gradelosalhisal

    17001200

    212011400

    314012000

    420013000

    530019999

    Total 8304 17599

    plz help me

  • select convert(varchar(5), grade), losal, hisal from {table}

    union all

    select 'Total', sum(losal), sum(hisal) from {table}

    I've converted the [grade] column to a varchar datatype in the first SELECT to make it possible to include the word 'Total' in the second SELECT.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
  • Even if the solution given will show the correct result, you should consider to do this calculations in the front end.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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