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

  1. #1

    Default sums and groups

    Hello,
    Below is my current query, I was wondering if anyone could tell me how to sum
    the opt_est_contract_val column correctly. The problem is with that query it
    repeats that value due to other data points that have to be joined in. I do
    have another column called opt_id that would be the logical column to group by
    but can't seem to get syntax right. If I group the whole query by opt_id, it
    will throw off my other sum. This is an Oracle DB 8.x or 9.x I believe.
    Thanks for any help.

    select count(*) as total, concat(concat(t1.user_last_name,',
    '),t1.user_first_name) as mgr, sum(bt_opportunity.opt_est_contract_val) as
    val_total, sum(dev_qty) as dev_total
    from bt_opportunity_case
    left join
    bt_device_conf on bt_opportunity_case.case_id = bt_device_conf.dev_case_id
    left join
    bt_case_status on bt_opportunity_case.case_status_id = bt_case_status.STATUS_ID
    left join
    bt_opportunity on bt_opportunity_case.case_opt_id = bt_opportunity.opt_id
    left join
    bt_user t1 on t1.user_id = bt_opportunity.OPT_NSM
    where case_state='Active'
    group by t1.user_last_name, t1.user_first_name

    dcm Guest

  2. Similar Questions and Discussions

    1. Permission groups
      We cannot connect to our site as we have no permsion groups showing. Does anyone know how we recreate the administrator permission group?
    2. Renaming groups
      Hello, Does anyone know if it is possible to rename a group in the 3D world, using Lingo? I have tried gWorld.group("oldname").name =...
    3. I'm still confused by the difference between Global Groups and Domain Local Groups
      Experts, I'm still confused by the difference between Global Groups and Domain Local Groups. I mean, they seem to me to accomplish the very same...
    4. Getting AD Groups
      Hi Gurus, I seek you expert advice on the following scenario:- Environment: Windows 2003, IIS6, Windows Integrated Authentication, .Net...
    5. UPDATE MULTIPLE ROWS IN ONE TABLE OBTAINING SUMS FROM ANOTHER TABLE
      UPDATE MULTIPLE ROWS IN ONE TABLE OBTAINING SUMS FROM ANOTHER TABLE I need to update a table with distinct sums from another table. I will...
  3. #2

    Default Re: sums and groups

    Not sure about your specific problem, but since you are summing field from a
    left joined table, you should change
    sum(bt_opportunity.opt_est_contract_val) as val_total
    to sum(coalesce(bt_opportunity.opt_est_contract_val, 0) as val_total

    Originally posted by: dcm
    Hello,
    Below is my current query, I was wondering if anyone could tell me how to sum
    the opt_est_contract_val column correctly. The problem is with that query it
    repeats that value due to other data points that have to be joined in. I do
    have another column called opt_id that would be the logical column to group by
    but can't seem to get syntax right. If I group the whole query by opt_id, it
    will throw off my other sum. This is an Oracle DB 8.x or 9.x I believe.
    Thanks for any help.

    select count(*) as total, concat(concat(t1.user_last_name,',
    '),t1.user_first_name) as mgr, sum(bt_opportunity.opt_est_contract_val) as
    val_total, sum(dev_qty) as dev_total
    from bt_opportunity_case
    left join
    bt_device_conf on bt_opportunity_case.case_id = bt_device_conf.dev_case_id
    left join
    bt_case_status on bt_opportunity_case.case_status_id = bt_case_status.STATUS_ID
    left join
    bt_opportunity on bt_opportunity_case.case_opt_id = bt_opportunity.opt_id
    left join
    bt_user t1 on t1.user_id = bt_opportunity.OPT_NSM
    where case_state='Active'
    group by t1.user_last_name, t1.user_first_name



    Dan Bracuk 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