Search code examples
sumsybaseinfomaker

Infomaker/Sybase Sum not working


If in sybase - infomaker file - I don't have any groups but since I'm using this to build pages in my software I need to be able to sum values. See attached screenshot. Totals. I would like the totals to be unique (or grouped by the id_key value).

The sum functionality has the following abilities. As I found here: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc00045_0250/html/ddref/BFCDFAJD.htm

Sum ( column { FOR range { DISTINCT { expres1 {, expres2  {, ... } } } } } )

The code I have is: sum( adult + senior_student + child + other for page) but what I'd like to do is have it "for id_key" but it doesn't seem to like that


Solution

  • If the names of your columns correspond to the headers above the answer should be: (you need to account for Null fields too).

    sum(((If(IsNull(adult), 0, adult))    +
    (If(IsNull(senior_student), 0, senior_student))  +
    (If(IsNull(child), 0,child)) +
    (If(IsNull(other), 0,other)))                
    for page distinct id_key)
    

    to sum by object:

     (If(IsNull(adult), 0, adult)) + 
     (If(IsNull(senior_student), 0, senior_student)) + 
     (If(IsNull(child), 0,child)) + 
     (If(IsNull(other), 0,other))