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

  1. #1

    Default major join?

    what i am trying to do to one poor table is:
    .................................................. .....get all
    departments....................................... ..............................
    .................................. <cfquery name='getdepts'
    datasource='survey_table'> SELECT DISTINCT(empDepartment) AS sdept FROM
    #tblnm# </cfquery> ...........................use output from getdepts to get
    count of how many people in each
    department........................................ ...... <cfoutput
    query='getdepts'> <cfset deptlst = '#sdept#'> <cfquery name='gtdptcnt'
    datasource='survey_table'> SELECT COUNT(empDepartment) AS dptctz FROM
    #tblnm# WHERE empDepartment = '#deptlst#' ; </cfquery>
    .................................................. ..find out how many people in
    each department fall into a certain category.................................
    <cfquery name='gtdptcnt1' datasource='survey_table'> SELECT
    COUNT(empDepartment) AS dptctz1 FROM #tblnm# WHERE (empDepartment =
    '#deptlst#') AND (memdt <> 0) ; </cfquery>
    .................................................. .........list departments, how
    many people/how many in category, percent in category...................... is
    there any way to do this as a join... keep getting messages that will only
    report one entry, etc, etc. one table has 32 departments and 350 employees...
    could be much larger.... churn, chur.... poor server. tnx in advance.

    ranger Guest

  2. Similar Questions and Discussions

    1. Is left-join faster then inner join?
      Some people said that using left-join is generally faster than inner join, is that true? Thanks...
    2. Major props to this NG
      Although I've been on-line since compuserv, I'm new to Flash developing. After finding this NG accidentally, I just wanted to congratulate y'all on...
    3. NArray indexing order: row major vs column major
      rubyists- am i the only one who finds the current NArray indexing order confusing: irb(main):001:0> na = NArray.to_na a=,] =>...
    4. HELP!!!...major problem
      Please help...I have made a flash movie in 16:9 format (1777px x 1000px) which I need to convert to a format that can be reproduced by a DVD player...
    5. Major dissapointment
      Hi group, The biggest dissapointment with Oracle so far: SQL> select count(*) from factTable; select count(*) from factTable * ERROR at line...
  3. #2

    Default Re: major join?

    I would like to help, but I'm a bit befuddled by your variable table name, so
    excuse me if I'm way off track. Would it help to use 'group by' to get counts
    of employees within each department? Ex (query1): <cfquery name='query1'
    datasource='????'> select count(employeeID) as empsindepartment, Department
    from employeetable group by Department order by Department </cfquery> Then
    loop over the departments? <cfloop query = 'query1'> <cfquery name='query2'
    datasource ='???'> select count(employeeID) as empsincategory from
    employeetable where Department=#query1.Department# and Category=whatever
    </cfquery> Calculate percentages using query1.empsindepartment and
    query2.empsincategory and output row for query1.department </cfloop> There
    are faster ways to do this, but this is the simplest way I know, and it
    shouldn't eat your server. (If I'm getting what your asking).

    DGH 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