Arranging Query Columns

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

  1. #1

    Default Arranging Query Columns

    This is my query

    <cfset Totals =
    queryNew("TotalPointsEarned,EarnedPointsCost,Total PointsRedeemed,RedeemedPointsC
    ost,PointsreedemedHandling,RedemedTotal,TotalPoint sUnRedeemed,UnRedeemedPointsCo
    st,PointsUnreedemedHandling,UnRedemedTotal")>
    <cfset queryAddRow(Totals)>
    <cfset querySetCell(Totals, "TotalPointsEarned",
    "#DecimalFormat(TotalPointsEarned)#")>
    <cfset querySetCell(Totals, "EarnedPointsCost",
    "#DecimalFormat(EarnedPointsEarned)#")>
    <cfset querySetCell(Totals, "TotalPointsRedeemed",
    "#DecimalFormat(ALLTotalPoints)#")>
    <cfset querySetCell(Totals, "RedeemedPointsCost",
    "#DecimalFormat(ALLPoints_Cost)#")>
    <cfset querySetCell(Totals, "PointsreedemedHandling",
    "#DecimalFormat(Handling)#")>
    <cfset querySetCell(Totals, "RedemedTotal", "#DecimalFormat(Total)#")>
    <cfset querySetCell(Totals, "TotalPointsUnRedeemed",
    "#DecimalFormat(ALLTotalUnredeemed)#")>
    <cfset querySetCell(Totals, "UnRedeemedPointsCost",
    "#DecimalFormat(ALLUnredeemed_points)#")>
    <cfset querySetCell(Totals, "PointsUnreedemedHandling",
    "#DecimalFormat(Unred_Handling)#")>
    <cfset querySetCell(Totals, "UnRedemedTotal",
    "#DecimalFormat(TotalHandling)#")>

    <cfdump var="#totals#"><cfabort>

    The problem is, if I dump it, the query doen't put the cells in the same order
    as I have created them. It autoArranges it to Alphabetical Order. Can anyone
    Help please?

    This is the sequence I want.

    TOTALPOINTSEARNED
    EARNEDPOINTSCOST
    TOTALPOINTSREDEEMED
    REDEEMEDPOINTSCOST
    POINTSREEDEMEDHANDLING
    REDEMEDTOTAL
    TOTALPOINTSUNREDEEMED
    UNREDEEMEDPOINTSCOST
    POINTSUNREEDEMEDHANDLING
    UNREDEMEDTOTAL

    But, this is the sequence I get.


    EARNEDPOINTSCOST
    POINTSREEDEMEDHANDLING
    POINTSUNREEDEMEDHANDLING
    REDEEMEDPOINTSCOST
    REDEMEDTOTAL
    TOTALPOINTSEARNED
    TOTALPOINTSREDEEMED
    TOTALPOINTSUNREDEEMED
    UNREDEEMEDPOINTSCOST
    UNREDEMEDTOTAL

    Any help will be much appriciated.

    Cheers.

    Maneesh Tikkiwal Guest

  2. Similar Questions and Discussions

    1. How to get the number of retrieved columns when doing a SQL Query
      Hello everyone, i just implement an own search site in MS CRM 1.2, which searches in a MS-SQL database. My question is, how to get the number...
    2. Specify Query Columns from From
      I want to create a form where a user can select from a drop down box which query colums they want to select and in what order. The form will be...
    3. displaying query in 2 columns
      Hi Guys, need your help on this please, I am trying to get the result of my query splited in 2 columns, where in the first column will have my first...
    4. How to span a query into 2 columns
      I have a query that produces a list of products and some of those products are subdivided into groups within the list. I have a query that...
    5. query results in 2 columns?
      I'm struggling to figure out how to do this properly. I have done a mySQL query to extract a list of names, and done a mysql_num_rows to determine...
  3. #2

    Default Re: Arranging Query Columns

    Why are you using CFDUMP to display our output? This tag is intended as a tool
    that Outputs variables for debugging purposes. Using cfdump, you can display
    the contents of simple variables, queries, arrays, structures, and WDDX
    variables created with cfwddx.


    Phil

    paross1 Guest

  4. #3

    Default Re: Arranging Query Columns

    cfdump is just for testing. don't worry about that. if you know the answer to my query please do let me know.
    Maneesh Tikkiwal Guest

  5. #4

    Default Re: Arranging Query Columns

    The answer is, if you use CDFUMP, you are stuck with the column names being
    sorted alphabetically. That is why I was implying as to why you would care
    about the sort order ,unless you actually planned on using CFDUMP for anything
    other than for testing and debugging. So, if you want to control the order of
    the columns, don't use CFDUMP.

    Phil

    paross1 Guest

  6. #5

    Default Re: Arranging Query Columns

    Hello Phill/ everyone.

    I do not intend to use cfdump for other then testing purposes. I am using this
    code to export the resul to excel using the custom tag QueryToExcel, I am
    passing the values as below

    <cfset Totals =
    queryNew("TotalPointsEarned,EarnedPointsCost,Total PointsRedeemed,RedeemedPointsC
    ost,PointsreedemedHandling,RedemedTotal,TotalPoint sUnRedeemed,UnRedeemedPointsCo
    st,PointsUnreedemedHandling,UnRedemedTotal")>
    <cfset queryAddRow(Totals)>
    <cfset querySetCell(Totals, "TotalPointsEarned",
    "#DecimalFormat(TotalPointsEarned)#")>
    <cfset querySetCell(Totals, "EarnedPointsCost",
    "#DecimalFormat(EarnedPointsEarned)#")>
    <cfset querySetCell(Totals, "TotalPointsRedeemed",
    "#DecimalFormat(ALLTotalPoints)#")>
    <cfset querySetCell(Totals, "RedeemedPointsCost",
    "#DecimalFormat(ALLPoints_Cost)#")>
    <cfset querySetCell(Totals, "PointsreedemedHandling",
    "#DecimalFormat(Handling)#")>
    <cfset querySetCell(Totals, "RedemedTotal", "#DecimalFormat(Total)#")>
    <cfset querySetCell(Totals, "TotalPointsUnRedeemed",
    "#DecimalFormat(ALLTotalUnredeemed)#")>
    <cfset querySetCell(Totals, "UnRedeemedPointsCost",
    "#DecimalFormat(ALLUnredeemed_points)#")>
    <cfset querySetCell(Totals, "PointsUnreedemedHandling",
    "#DecimalFormat(Unred_Handling)#")>
    <cfset querySetCell(Totals, "UnRedemedTotal",
    "#DecimalFormat(TotalHandling)#")>

    The problem is, on the excel sheet, its not coming as I have defined them. The
    column names are sorted in alphabetical order and are not displayed in the
    sequence as I create them.

    Any help will be much appriciated.

    Regards

    Maneesh Tikkiwal Guest

  7. #6

    Default Re: Arranging Query Columns

    > I do not intend to use cfdump for other then testing purposes. I am using this
    > code to export the resul to excel using the custom tag QueryToExcel, I am
    > passing the values as below
    Does this QueryToExcel custom tag (I can find no reference to this custom
    tag on google) not permit you to specify which order to process the
    columns?

    You're kind of at the mercy of how QueryToExcel has been coded...

    --
    Adam
    Adam Cameron Guest

  8. #7

    Default Re: Arranging Query Columns

    Have you looked at CFX_Exce at [url]http://www.cftagstore.com/tags/cfxexcel.cfm?[/url] Maybe that will suit your purpose.
    jdeline 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