Results 1 to 2 of 2

Thread: sum(+) sql

  1. #1
    Join Date
    Feb 2005
    Posts
    13

    Lightbulb Unanswered: sum(+) sql

    I have a table like this;

    C:\Documents and Settings\busra>db2 select * from deneme1

    IDS MTUTAR YTUTAR TTUTAR
    ----------- ----------------- ----------------- -----------------
    1 100.00000 200.00000 300.00000
    1 150.00000 - 50.00000
    1 13.00000 133.00000 -
    1 0.00000 13.00000 133.00000

    4 record(s) selected.

    and I want to sum these three columns and it looks like
    C:\Documents and Settings\busra>db2 select mtutar+ytutar+ttutar from deneme1

    1
    -------------------
    600.00000
    -
    -
    146.00000

    4 record(s) selected.

    Hovewer I want to see;

    1
    -------------------
    600.00000
    200.00000
    146.00000
    146.00000

    how can I do that?

    I hope I can explain what I want

  2. #2
    Join Date
    Aug 2004
    Posts
    330
    Assuming the - means null value.

    select coalesce(MTUTAR,0) + coalesce(YTUTAR,0) + coalese(TTUTAR,0)
    from deneme1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •