Comparing 2 values in a SQL Select

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

  1. #1

    Default Comparing 2 values in a SQL Select

    Hi Folks -

    I was wondering if anybody knows how to get a single value result from 2
    previous calculated results...

    Here's my query...
    __________________________________________________ ______________________
    Select Year(dateeffective) as year1,Month(dateeffective) as
    month1,count(uwaction) as total1,
    Sum(bound_premium) as Bound1,Sum(quoted_premium) as Quoted1,
    IIF(Bound1>=Bound1,bound1,quoted1) as new_output
    From q_quotes_tbl
    Where dateeffective >= '01/01/05' and dateeffective <= '09/20/05' and lob_id=3
    and quotetype='new' and
    ((Cast(bound_premium as numeric) is not null and Cast(bound_premium as
    numeric) > 0) or
    (Cast(quoted_premium as numeric) is not null and Cast(quoted_premium as
    numeric) > 0))

    group by year(dateeffective),Month(dateeffective)
    order by year(dateeffective),Month(dateeffective)
    __________________________________________________ ______________________
    I am having a problem with this line:
    IIF(Bound1>=Quoted1,bound1,quoted1) as new_output


    What I want to do is to Sum two different fields, and then show me only the
    greater of the two fields totals.

    Any and all help is appreciated.

    Thanks,

    Doug

    Fordian-Slip Guest

  2. Similar Questions and Discussions

    1. #39579 [NEW]: Comparing zero & string values in boolean comparison has unexpected behaviour
      From: iain at workingsoftware dot com dot au Operating system: FreeBSD 6.1 PHP version: 5.2.0 PHP Bug Type: Class/Object...
    2. Comparing 2 columns in my select
      I have 3 columns, name - price1 - price2 I want to compare price1 against price2 during my select and only return the greatest value to my...
    3. Difficulty with SELECT statement using TWO values
      hello, I am having difficulty getting select statement to work. i need to SELECT value1, value2, value3, FROM table WHERE garage = requestform...
    4. Comparing values
      i have created three fields named (username, surname & pin) and when the user enters in the information, i want it to compare the values from three...
    5. comparing field values
      Hi I have a problem...I need to be able to compare the values entered in a series of fields against a set of rules. For example, lets say I have...
  3. #2

    Default Re: Comparing 2 values in a SQL Select

    how about
    Select Year(dateeffective) as year1,Month(dateeffective) as
    month1,count(uwaction) as total1,
    Sum(bound_premium) as Bound1,Sum(quoted_premium) as Quoted1,
    case when bound1 >= quoted1 then bound1 else quoted1 end as new_output
    etc


    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