Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Posts
    2

    Unanswered: 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?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    How do you expect your result set to look?

  3. #3
    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.

  4. #4
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    group by
    Dave

Posting Permissions

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