Less than or greater than Decode Function

Can we use less than or greater than (relational operator) operator in decode function

Use Case instead.
Not sure if you need it in your resultset or your where clause.
Simple examples:
MHO%xe> with numbers as(
  2  select 1 a, 3 b from dual union all
  3  select 2 a, 3 b from dual union all
  4  select 3 a, 3 b from dual union all
  5  select 4 a, 3 b from dual union all
  6  select 5 a, 3 b from dual
  7  )
  8  select 'QRY1'
  9  ,      a
10  ,      b  
11  from   numbers
12  where (case when a >= b then 1 end) = 1
13  union all
14  select 'QRY2'
15  ,      case when a < b then b else 0 end
16  ,      case when b < a then a else 0 end
17  from numbers;
'QRY          A          B
QRY1          3          3
QRY1          4          3
QRY1          5          3
QRY2          3          0
QRY2          3          0
QRY2          0          0
QRY2          0          4
QRY2          0          5

Similar Messages

  • I have a manual that contains headings and index entries that contain less than and greater than characters, and . The Publish to Responsive HTML5 function escapes these correctly in the main body of the text but does not work correctly in either the C

    I have a manual that contains headings and index entries that contain less than and greater than characters, < and >. The Publish to Responsive HTML5 function escapes these correctly in the main body of the text but does not work correctly in either the Contents or the Index of the generated HTML. In the Contents the words are completely missing and in the index entries the '\' characters that are required in the markers remain in the entry but the leading less than symbol and the first character of the word is deleted; hence what should appear as <dataseries> appears as \ataseries\>. I believe this is a FMv12 bug. Has anyone else experienced this? Is the FM team aware and working on a fix. Any suggestions for a workaround?

    The Index issue is more complicated since in order to get the < and > into the index requires the entry itself to be escaped. So, in order to index '<x2settings>' you have to key '\<x2settings\>'. Looking at the generated index entry in the .js file we see '<key name=\"\\2settings\\&gt;\">. This is a bit of a mess and produces an index entry of '\2settings\>'. This ought to be '<key name=\"&amp;lt;x2settings&amp;gt;\" >'. I have tested this fix and it works - but the worst of it is that the first character of the index entry has been stripped out. Consequently I cannot fix this with a few global changes - and I have a lot of index entries of this type. I'm looking forward to a response to this since I cannot publish this document in its current state.  

  • Greater than in a DECODE function

    Hi,
    Can anybody help?
    I need to convert the following pseudo code into sql format:
    if the difference between interview date and entered date is less than 10 days
    then count the number students within the 10 days
    else count the number of students who exceed the 10 days
    I have tried using the CASE format but this just produced of list of 'within' and 'exceeds'
    SELECT CASE WHEN to_date(idc, 'dd-mon-yyyy') - to_date(edc, 'dd-mon-yyyy') BETWEEN 0 AND 10 THEN 'WITHIN' ELSE 'EXCEED' END
    Anyone got any ideas?
    Thanks Jen

    As SK says, your requirement is a slightly confusing. My assumption is that you want to do two counts, one for students within the bounds and one for students who exceed the bounds. Well you can do that like this:
    SELECT sum(CASE WHEN to_date(idc, 'dd-mon-yyyy') - to_date(edc, 'dd-mon-yyyy') BETWEEN 0 AND 10 THEN 1 ELSE 0 END) WITHIN
           , sum(CASE WHEN to_date(idc, 'dd-mon-yyyy') - to_date(edc, 'dd-mon-yyyy') > 10 THEN 0 ELSE 1 END) EXCEEDs
    FROM your_tableRas malai, APC

  • Is there replacement for (less than) and (greater than) in Oracle 10g?

    Hi,
    In the User Java Application using Oracle's > (less than) or > (greater than) is not working.
    Can anyone help me onthis for any feature in Oracle 10g instead of using less than or greater than
    Thanks and Regards

    Hi,
    What do yyou mean by "it's not working"?
    Maybe you could use sign function, instead.
    with t as (select 2 x, 3 y from dual union all
               select 2 x, 1 y from dual union all
               select 2 x, 2 y from dual)
    select t.*
      from t
    where sign(y - x) = - 1;
             X          Y
             2          1
    1 row selected.Regards
    Peter

  • Greater Than Less Than

    Dear all,
    I am Using oracle 10g R2 database on windows.
    I have a doubt that,
    If I have a 'Date' datatype column suppose a and want to (select Less than sysdate and greater than Sysdate-31(One Month).
    e.i.
    select a,b,c from T where a Less Than Sysdate-31(One month.);How can i do this.
    Thanks,
    Chanchal Wankhade.

    Shinegar wrote:
    I had not considered the effect on an index with TRUNC. Thank you for pointing that out.
    TRUNC doesn't actually remove time as you can see below
    SELECT TO_CHAR(TRUNC(SYSDATE),'MM/DD/YYYY HH:MM:SS AM') "Today's Date and Time" from DUAL;
    Today's Date and Time
    01/19/2012 12:01:00 AMLet's say sysdate = Jan 19, 2012 11:00:00 AM
    As shown above, trunc(sysdate) = Jan 19, 2012 12:01:00 AM
    So, trunc(sysdate) -1 = Jan 18, 2012 12:01:00 AM
    Removing the trunc from column a
    select a,b,c
    from T
    where a between trunc(sysdate)-1 and trunc(sysdate);will also remove all data that is greater than Jan 19, 2012, 12:01:00 AM so you would only see data from one day -- Jan 18th.
    Adding the trunc to column a returns all the data from Jan 18th and 19th.
    It is my experience that users will ask for a date range, but then will ask for just one day. If Column a is not truncated, then no rows would be returned when between trunc(sysdate) and trunc(sysdate).
    Most programmers will not use trunc(sysdate) in the where clause, but would use a variable with value assigned of sysdate or trunc(sysdate) as it provides more flexibility.
    If you do not want to use trunc on column a, then the where clause should be BETWEEN trunc(sysdate) - 31 AND sysdate.
    Edited by: Shinegar on Jan 19, 2012 12:40 PMThe trunc function does not remove the time portion, but it does set it to midnight. Or at least i would if you used the correct format mask in your TO_CHAR. The mask for minutes is MI not MM.
    SQL> SELECT TO_CHAR(TRUNC(SYSDATE),'MM/DD/YYYY HH:MI:SS AM') am_pm,
      2         TO_CHAR(TRUNC(SYSDATE),'MM/DD/YYYY HH24:MI:SS') mil_time
      3  from dual;
    AM_PM                  MIL_TIME
    01/19/2012 12:00:00 AM 01/19/2012 00:00:00John

  • Reporting - using the less than function or the filter.

    Hi,
    I am trying to make a report about the opportunities and their values. I decided to add 3 times the same revenue colomn because I wanted the first colomn to show me the revenus under 10000, the seconde one, the revenues between 10000 and 100000 and the third one, the revenues greater than 100000.
    In order to do that, I selected the function button in the creation of my rapport and I tried it 2 different ways.
    1° I choose the filter button (in the function pop up), select the field on my left panel and choose for the first colomn for example "less than" 100000.
    The formula that appears in this one:
    FILTER("- Revenue Custom Metrics".S_CUR_0+"- Revenue Custom Metrics".S_CUR_0 USING ("- Revenue Custom Metrics".S_CUR_0 < 100000))
    When I try to execute, I get this error message:
    [nQSError: 10058] A general error has occurred. [nQSError: 22034] Aggregate is not allowed within USING clause of a FILTER operator. (HY000)
    SQL Issued: SELECT "- Account Custom Attributes".PICK_3, "- Opportunity Custom Attributes".TEXT_30, "- Revenue Custom Metrics".S_CUR_0, FILTER("- Revenue Custom Metrics".S_CUR_0+"- Revenue Custom Metrics".S_CUR_0 USING ("- Revenue Custom Metrics".S_CUR_0 < 100000)), Opportunity."Current Sales Stage" FROM "Opportunity Analysis"
    2° I try to use the "<" sign without using the filter. So I click on the appropriate colomn and add < 100000, so it becomes:
    "- Revenue Custom Metrics".S_CUR_0+"- Revenue Custom Metrics".S_CUR_0 < 100000
    I receive the following error message:
    [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <<>: Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: SELECT "- Account Custom Attributes".PICK_3, "- Opportunity Custom Attributes".TEXT_30, "- Revenue Custom Metrics".S_CUR_0, "- Revenue Custom Metrics".S_CUR_0+"- Revenue Custom Metrics".S_CUR_0 < 100000, Opportunity."Current Sales Stage" FROM "Opportunity Analysis"
    Can someone tell me what I did wrong ?
    Thanks a lot

    firstly, didn't understand why you are adding the metric to itself in the Fx.
    secondly, you could have used case when statements, something like CASE WHEN metric <10000 THEN metric ELSE NULL END and so forth

  • "Less than 40%", "In between 40 and 70%", "Greater than 70%

    ADF Experts,
    In DVT like funnel chart, is it possible to change the graph bifurcation based on custom requirement.
    For eg : Funnel chart creates the funnel like "Less than 40%", "In between 40 and 70%", "Greater than 70%" . Is it possible to change this to any custom value ?
    thnks
    Jdev 11.1.1.5

    Hi,
    see "Treshold" in
    http://download.oracle.com/docs/cd/E21764_01/apirefs.1111/e12418/tagdoc/dvt_funnelGraph.html
    +"The number of threshold, each threshold range and color can be customized in the graph bean. These functions are not exposed to the faces layer yet, but application may use a graph binding to access these functions in the graph engine."+
    Frank

  • Decode Statement Less Than or Equal To

    Hi,
    I want to use a decode statment to search a range of accounts, and return a text statement:
    Here is my original statement it works but I need a range:
    DECODE(GL Standard Balances DX."Account 1",'00040501','OHIP Revenue(40501/40502)','00040502','OHIP Revenue(40501/40502)')
    What I want to do is, if the GL Standard Balances DX."Account 1" is greater than '00040501' and less than '00040502' then return the text "OHIP Revenue (40501/40502)".
    Any help would be great.

    Hi,
    Best for you is to use case rather than decode
    case when GL Standard Balances DX."Account 1" between '00040501' and '00040502'
    then 'OHIP Revenue(40501/40502)'
    else ''
    end;
    Tamir

  • I am using a timed while loop and am unable to get the loop to run at a speed of less than 1ms (I am currently using the Wait(ms) function). How can I get a faster response?

    I am trying to create a virtual engine within a timed while loop and am unable to get the loop to run at a speed of less than 1ms (I am currently using the Wait(ms) function). This does not however allow realistic engine speeds. How can I overcome this? I have access to a PCI-MIO-16E-4 board.

    andyt writes:
    > I am using a timed while loop and am unable to get the loop to run at
    > a speed of less than 1ms (I am currently using the Wait(ms) function).
    > How can I get a faster response?
    >
    > I am trying to create a virtual engine within a timed while loop and
    > am unable to get the loop to run at a speed of less than 1ms (I am
    > currently using the Wait(ms) function). This does not however allow
    > realistic engine speeds. How can I overcome this? I have access to
    > a PCI-MIO-16E-4 board.
    Andy,
    Unless you use a real time platform, getting extactly 1 ms loop rate
    (or even less) is impossible. It starts getting troublesome at about
    0.1 Hz for standard operating systems.
    I'd tackle your problem with "if i mod 10 == 0 then sleep 1 ms".
    Of
    course this is jerky by design.
    HTH,
    Johannes Nie?

  • Greater Than or Less Than using String Variables

    I seem to have a problem when trying to sort an ALPHABETIC LIST, seeing if one text field is greater tan or less than another.
    i.e. Lets say my variables are called FirstLetter and SecondLetter.
    FirstLetter="A", SecondLetter="B"
    So as an example and a test....Can I ask ...
    IF SecondLetter>FirstLetter Then
            Textwindow.WriteLine(SecondLetter + "  >" + FirstLetter)
    Else
            Textwindow.WriteLine(FirstLetter + " >= " + SecondLetter)
    Endif
    I seem to be fine and program working well with numeric values in variables but the '> & <' feature does not seem to work with Text ?
    Any help really appreciated
    Thanks
    Dave

    We gotta get their ASCII/UNICODE value before comparing them:
    firstLetter = "A"
    secondLetter = "B"
    If Text.GetCharacterCode(firstLetter) > Text.GetCharacterCode(secondLetter) Then
    Textwindow.WriteLine(FirstLetter + " > " + SecondLetter)
    ElseIf Text.GetCharacterCode(firstLetter) < Text.GetCharacterCode(secondLetter) Then
    Textwindow.WriteLine(SecondLetter + " > " + FirstLetter)
    Else
    Textwindow.WriteLine("They're the same " + FirstLetter + " letter!")
    EndIf
    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

  • Camel Query : Calender list : Get Items agains given date that must be greater than and eqaul to start date and greater less than or equal to end date ?

    Camel Query : Calender list : Get Items agains given date that must be greater than and eqaul to start date and greater less than or equal to end date ?
    A Snap of Employee holiday list
    Case : Anne juul Sondergaar is on leave from 05-06-2014 to 07-06-2014
    I need a query to check wheither Anne juul is on leave at 06-06-2014 ????
    I am using this query that return nothing
    SPQueryquery =
    newSPQuery();
                                query.Query =
    @"<Where>
    <And>
    <And>
    <Leq>
    <FieldRef Name='Til' />
    <Value Type='DateTime'>"
    + WorkingStartDate.ToString("yyyy-MM-dd")
    + @"</Value>
    </Leq>
    <Geq>
    <FieldRef Name='Fra' />
    <Value Type='DateTime'>"
    + WorkingStartDate.ToString("yyyy-MM-dd")
    + @"</Value>
    </Geq>
    </And>
    <Eq>
    <FieldRef Name='Medarbejdere' />
    <Value Type='Lookup'>"
    + EmployeeName.Trim() +
    @"</Value>
    </Eq>
    </And>
    </Where>"
                                query.ViewFields =
    " <FieldRef Name='ID' />";
    Ahsan Ranjha

    Hello,
    Download CAML query builder from below location and use it to build your query:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/f7b36ebc-6142-404a-8b04-9c87de272871/where-can-i-download-the-u2u-caml-query-builder-for-sharepoint-2010may-i-know-the-exact-link?forum=sharepointgeneralprevious
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to implement 'less than' in choosing functions depending on numeric input

    I have a 1D array and I want to split what happens with different values
    I made it so that the array outputs an element, with a scroll bar to change the element
    The array is random 
    When the element is < 512 I want A to happen
    When the element is > 512 I want B to happen 
    I've played around with case structure but what confuses me is the less than and greater than fucntion, it's output is a boolean
    If it changes anything I am connectiong the the output to a multiply functino 
    Thanks!  
    Solved!
    Go to Solution.

    sofiakyle wrote:
    I have a 1D array and I want to split what happens with different values
    I made it so that the array outputs an element, with a scroll bar to change the element
    The array is random 
    When the element is < 512 I want A to happen
    When the element is > 512 I want B to happen 
    I've played around with case structure but what confuses me is the less than and greater than fucntion, it's output is a boolean
    If it changes anything I am connectiong the the output to a multiply functino 
    Thanks!  
    I would recommend classes or getting some books on LabVIEW to study.  A basic question like this indicates you haven't yet been able to make the transition from text-based language to LabVIEW with any confidence.  It took me a while to be comfortable with it, so I feel your pain. 
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Does specified lsn should greater than or less than min_autonosync_lsn when setting up a "initialize from lsn" subscription?

    Hello,
    For setting up a "initialize from lsn" type subscription successfully, Does the lsn for @subscriptionlsn parameter need greater than or less than the  min_autonosync_lsn (syspublications) ?
    I read two versions of this: one is lsn >min_autonosync_lsn ,the other is lsn <min_autonosync_lsn. I agree lsn >min_autonosync_lsn.
    Thanks

    Basically it means that the lsn should be retrievable somewhere in the distribution database.  So it has to be> than the min otherwise you would need to reinitialize.
    Note that this is only important when you are mirroring the subscription database.
    looking for a book on SQL Server 2008 Administration?
    http://www.amazon.com/Microsoft-Server-2008-Management-Administration/dp/067233044X looking for a book on SQL Server 2008 Full-Text Search?
    http://www.amazon.com/Pro-Full-Text-Search-Server-2008/dp/1430215941

  • HT1688 Where are the less than and greater than symbols?

    where are the less than < and greater than > symbols?

    Assuming rawValue of the total field is returning as "10000".
    In the Calculate event of the Total field, write the following with Java Script as language.
    VP_Signature.presence = "hidden";
    Officer_Signature.presence = "hidden";
    if(total.rawValue>10000){
         VP_Signature.presence = "visible";
         Officer_Signature.presence = "visible";    
    else{ 
         VP_Signature.presence = "hidden"; 
         Officer_Signature.presence = "visible";
    Thanks
    Srini

  • Numbers '08 "If" with a greater or less than answer

    Hi all - I have a cell with a sum D & E28 (merged cell) that I want another cell B30 to display a value based on what is in cell D & E28.
    If cell D & E28 is 8 or less I want B30 to say 8. If D & E28 is greater than 8.001 but less than 12 I want B30 to say 12 and if D & E28 is greater than 12.001 but less then 18 I want B30 to say 18
    Any ideas?
    Thanks
    Peter

    pdmjr,
    =IF(ROUND(D28,3)<=8.001, 8, IF(ROUND(D28,3)<=12.001, 12, IF(ROUND(D28,3)<=18, 18, "Over 18")))
    should do it for you.
    The nested IF statements handle your logic. The ROUND statements handle internal math errors and your need to break at .001. You didn't say what to do with inputs of 18 or greater, so I suggested a text string for that case.
    The form of the IF statement is: If (logical statement) is True, Then do this, Else do this. Your case requires three tests. You could quibble about a value that is, say, 12.0011 and rounds to 12.001, but I doubt you are concerned about that level of detail. If so let me know.
    Does this help?
    Regards,
    Jerry
    Message was edited by: Jerrold Green1

Maybe you are looking for

  • Non numeric value in numeric field giving error

    Hi All I am using BAPI for creating sales order. If user is giving non numeric value in Quantity field it is giving error. Because quantity field data type is Double. Please Help. Thanks Raktim

  • Some problems with MS VM

    Hi, Anyone knows how to uninstall the Microsoft Virtual Machine from Internet? I try to include the components Java Swing into my applet, but when I run my applet in a computer with the MS VM a gray window appears. I have an script in HTML+JS to dete

  • Crontab doesn't work

    Hi! I've got following strings in crontab: 00 20 * * *  /home/user/script.sh 2>&1 > /dev/null 0-59 * * * * /bin/date However, both of them doesn't work. There's no output in terminal for second string. Here's what /var/log/crond.log shows (for "date"

  • Cannot connect to SQL Server databases

    All of a sudden I can't connect to SQL server databases from my local machine. The databases are on a web server. It just started happening, and I never had a problem with it before. I can't connect to them in the coldfusion administrator, and I can'

  • 6101 to PC suite via IR

    Am I alone in not being able to connect my 6101 via Infra Red to the PC Suite. Yes it is activated both on phone and thru the wizard and I have adjusted the speed. I wonder is I am trying for the impossible!!