Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Column Totals

    Is there an easy way to total a column of numbers returned in a query? For
    example, I am producing a sales report for 10 sales people. The database query
    returns 10 rows, each with a sales amount. I need to compute a total of those
    10 amounts. I am currently re-querying the database without a 'group by'
    clause to get the total amount. It seems like there should be a CF function to
    get that number without an additional query.

    nav1 Guest

  2. Similar Questions and Discussions

    1. datagrid column calculate totals
      Hi - hope someone can help with this datagrid issue - I think it's just a small bit of code I've got to tweak. Might be some useful information to...
    2. Looping through all rows and columns (to get sub-totals for each column and row)
      Is there a way to loop through all rows and columns in order to fill a sub-totaled columns and a sub-totaled row (footer). I thought about doing...
    3. NEWBIE - Column Totals in Footer of mxDataGrid
      Greetings, How can I display the total of one or several columns in the footer of an MxDataGrid? If there is a link to a tutorial or article,...
    4. ASP totals and sub-totals from an Access or SQL DB
      Hi All I know I posted a similar topic a few days ago, but I may have gone on a bit of a rant with it. Basically I want to know if it is...
    5. totals at the TOP?
      Is there any way to get FooterText to show at the top of the grid instead of the bottom? We have hundreds of pages of grids that are almost always...
  3. #2

    Default Re: Column Totals

    SELECT ..., SUM(salesAmount) AS total, ...

    jdeline Guest

  4. #3

    Default Re: Column Totals

    <CFSET VARIABLES.TOTAL = 0>
    <CFOUTPUT QUERY="MYQUERY">
    <CFSET VARIABLES.TOTAL = VARIABLES.TOTAL + MYQUERY.FIELDNAME>

    .. display fields as normal

    </CFOUTPUT>
    <CFPOUTPUT># VARIABLES.TOTAL#</CFOUTPUT>

    Scott*e Guest

  5. #4

    Default Re: Column Totals

    And another method ...

    <cfset grandTotal = ArraySum(ListToArray(ValueList(yourQuery.SalesAmou ntColumn)))>
    mxstu Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139