Query Help

  • I need add multiple rows and take sum of that row in to single column

    Server|||| Cost

    abcd ||||| 75

    abcd ||||| 25

    dtgr ||||| 65

    dtgr ||||| 35

    table should lok like below.

    Server||||| Cost

    abcd ||||| 100

    abcd ||||| 100

    dtgr ||||| 100

    dtgr ||||| 100

    or

    abcd |||||100

    dtgr |||||100

  • DBA12345 (4/29/2013)


    I need add multiple rows and take sum of that row in to single column

    Server|||| Cost

    abcd ||||| 75

    abcd ||||| 25

    dtgr ||||| 65

    dtgr ||||| 35

    table should lok like below.

    Server||||| Cost

    abcd ||||| 100

    abcd ||||| 100

    dtgr ||||| 100

    dtgr ||||| 100

    or

    abcd |||||100

    dtgr |||||100

    select

    Server,

    sum(Cost) as TotalCost

    from

    dbo.MyTable

    group by

    Server

    order by

    Server;

  • Thanks alot..its working

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

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