If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > sum(+) sql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-14-05, 11:03
busrae busrae is offline
Registered User
 
Join Date: Feb 2005
Posts: 13
Lightbulb 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
Reply With Quote
  #2 (permalink)  
Old 11-14-05, 11:27
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
Assuming the - means null value.

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On