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 function syntax

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-03-11, 13:12
DB_NewbieWoods DB_NewbieWoods is offline
Registered User
 
Join Date: May 2011
Posts: 2
Sum function syntax

I am new to integrating DB2 into our website, and have managed to get the select statement to pulling everything but one column that I just want the sum for all records in one table.

Here is the code I have written:

SELECT PM.PMPART, PM.PMDESC, PM.PMSUBF, PCRTL.PRRTL, SUM(int(ISP.ISSTOH)) AS TAVAIL FROM PM, PCRTL, ISP WHERE PM.PMPART = @pNum and PM.PMPCLS IN ('43','45') and PCRTL.PRPART = PM.PMPART and ISP.ISPART = PM.PMPART

However anytime I use SUM() around a field, it causes an error.

Can anyone help?
Reply With Quote
  #2 (permalink)  
Old 05-03-11, 13:24
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
How do you expect your result set to look?
Reply With Quote
  #3 (permalink)  
Old 05-03-11, 13:27
DB_NewbieWoods DB_NewbieWoods is offline
Registered User
 
Join Date: May 2011
Posts: 2
I want one row with the data for each column of the 2 main tables (PM, PCRTL) and then on ecolumn with the sum of the ISSTOH column of the ISP table where my part numbers match.
Reply With Quote
  #4 (permalink)  
Old 05-03-11, 13:59
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
group by
Dave
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