Crosstab Query with Date Fields

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Crosstab Query with Date Fields

    Pulling my hair out!
    Ok here's what I got:
    I need to output 2 queries with 2 different datefields with different Years (2
    max) in tabular format
    EXAMPLE:
    2004 2005
    Jan Feb March April ...etc Jan Feb March April ...etc
    2 3 0 5 0 1 3 8


    Total count by month and year will be placed under appropriate colum.

    I can't get it to work. Anyone have any insight to this one?


    mostlySimple Guest

  2. Similar Questions and Discussions

    1. Crosstab Query Export
      I have a crosstab query which i want to export, using a Macro, as an excel sheet to a specific folder (using TransferSpreadsheet or TransferText...
    2. Crosstab query with multiple value fields
      Hi again, Is it possible for a crosstab query to have multiple value fields ? The way I'm working now is to create separate crosstabs (about...
    3. Creatin a Datasheet Form that looks like CrossTab Query?
      I have produced a crosstab query that allows me to view the data in the desired format, but I can't update because its a crosstab. Field One is...
    4. Crosstab query - Nearly there!
      Try: select a.status, (select count(*) from #crosstab where tsize = 20 and status =a.status) , (select count(*) from #crosstab where tsize = 40...
    5. No true Crosstab Query in Oracle???
      Gavin John Fowler wrote: Cross-tabulation is easily accomplished using DECODE and CASE. Just alias the resulting columns. To handle an...
  3. #2

    Default Re: Crosstab Query with Date Fields

    can you post some code...?
    jorgepino Guest

  4. #3

    Default Re: Crosstab Query with Date Fields

    It's hard to tell without some code exactly what you are trying to do. You can
    output queries to put data or totals into arrays, then use those arrays to
    display the output. You can also have your output append text to a variable and
    then display that variable to the web page. You can even output the same query
    more than once to format different parts of your page.

    Give us some more details about what you are doing.

    -Paul

    dempster Guest

  5. #4

    Default Re: Crosstab Query with Date Fields

    Sorry I rushed that initial statement. So here's a more detailed spec.

    -User inputs 1 date
    -The report will show Individuals on the left side and months across the top
    (maximum of 24 months or 2 year window)
    -The data under each month will be the count of Individuals with ?A Date?
    equal to the calendar month
    -But individual dates to left (dates less than the 1 date input) of the 1 date
    input will represent a different date field from database than the date results
    to the right (dates greater than the 1 date input).

    I initially tried to take the results of a query pick it apart using arrays
    came close just couldn't spilt which date sets to show from left or right of
    date input. I don't know how to write a query to produce results in a tabular
    format.

    Hope that was a little clearer than the first time around. Thanks in advance
    for any help you may provide.
    \
    webs


    mostlySimple Guest

  6. #5

    Default Re: Crosstab Query with Date Fields

    User inputs 1 date
    -The report will show Individuals on the left side and months across the top
    (maximum of 24 months or 2 year window)
    -The data under each month will be the count of Individuals with ?A Date?
    equal to the calendar month
    -But individual dates to left (dates less than the 1 date input) of the 1 date
    input will represent a different date field from database than the date results
    to the right (dates greater than the 1 date input).

    I initially tried to take the results of a query pick it apart using arrays
    came close just couldn't spilt which date sets to show from left or right of
    date input. I don't know how to write a query to produce results in a tabular
    format.

    Heres a query used to pull the data:

    <cfquery name="t">
    Select t1.date1,t1.date1,t2.fname,t2.lname
    FROM table1 t1, table2 t2_referral ar
    WHERE t1.userID = t2.userID
    </cfquery>

    Yes 1 input date. date1 less than input date and date2 greater than input date.

    The data under each month will be the count of Individuals with ?A date1 or
    date2? equal to the calendar month

    Range of 2 years or 24 months.



    mostlySimple Guest

  7. #6

    Default Re: Crosstab Query with Date Fields

    You can use a brute-force method and just loop through each table cell running
    a query -- or query of queries.

    In order to get all the data at once, you will want to use SQL techiniques
    like grouping tables or user defined functions.

    [url]http://www.sswug.org/see/21626[/url] is an excellent article (paid subscription
    required).


    MikerRoo Guest

  8. #7

    Default Re: Crosstab Query with Date Fields

    ha, ha...thats a good idea.



    mostlySimple 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