Help: Search record set where the value is not between adjacent records

I need to find a record of database. I find it too complex for my current knowledge of SQL. Please help, thanks.
--set 1
    select 1 id, 1 a, 2 e from dual union
    select 1 id, 2 a, 3 e from dual union
    select 1 id, 5 a, 6 e from dual union
    select 1 id, 6 a, 7 e from dual union
    select 1 id, 9 a, 10 e from dual union

--set 2
    select 2 id, 1 a, 3 e from dual union
    select 2 id, 2 a, 3 e from dual union
    select 2 id, 3 a, 4 e from dual union
    select 2 id, 6 a, 7 e from dual union
    select 2 id, 9 a, 10 e from dual 
input: output:
1 norec
2 norec
3 norec
4 id = 1
5 id = 2
8 id = 1 id = 2

Maybe that's what you want

Use your parameter instead of numbers.

SQL> CREATE TABLE test1 AS  SELECT 1 ID, 1 A, 2 E FROM dual UNION
  2      SELECT 1 ID, 2 A, 3 E FROM dual UNION
  3      SELECT 1 ID, 5 A, 6 E FROM dual UNION
  4      SELECT 1 ID, 6 A, 7 E FROM dual UNION
  5      SELECT 1 ID, 9 A, 10 E FROM dual UNION
  6      SELECT 2 ID, 1 A, 3 E FROM dual UNION
  7      SELECT 2 ID, 2 A, 3 E FROM dual UNION
  8      SELECT 2 ID, 3 A, 4 E FROM dual UNION
  9      SELECT 2 ID, 6 A, 7 E FROM dual UNION
 10      SELECT 2 ID, 9 A, 10 E FROM dual;

Table created.

SQL>
SQL> SELECT DISTINCT ID
  2    FROM test1 t1
  3   WHERE NOT EXISTS
  4            (SELECT ID
  5               FROM test1 t2
  6              WHERE     1 <= E
  7                    AND 1 >= A
  8                    AND t1.ID = t2.ID);

no rows selected

SQL>
SQL> SELECT DISTINCT ID
  2    FROM test1 t1
  3   WHERE NOT EXISTS
  4            (SELECT ID
  5               FROM test1 t2
  6              WHERE     4 <= E
  7                    AND 4 >= A
  8                    AND t1.ID = t2.ID);

        ID
----------
         1

SQL>
SQL> SELECT DISTINCT ID
  2    FROM test1 t1
  3   WHERE NOT EXISTS
  4            (SELECT ID
  5               FROM test1 t2
  6              WHERE     8 <= E
  7                    AND 8 >= A
  8                    AND t1.ID = t2.ID);

        ID
----------
         1
         2

SQL> 

If you would like your reesults in the same line then

SQL> SELECT LTRIM (MAX (SYS_CONNECT_BY_PATH (str, ',')), ',') result
  2    FROM (SELECT DISTINCT ID,'id='||ID str, ROWNUM rn
  3            FROM test1 t1
  4           WHERE NOT EXISTS
  5                    (SELECT ID
  6                       FROM test1 t2
  7                      WHERE     8 <= E AND 8 >= A AND t1.ID = t2.ID) ORDER BY ID)
  8  START WITH rn = 1
  9  CONNECT BY PRIOR ID < ID;

RESULT
---------------------------------------------------------------------------------------
id=1,id=2

SQL> 

G.

Published by: Ganesh aboumagahrif on March 21, 2011 12:18 AM

Tags: Database

Similar Questions

  • Request to remove row where the value of column contains alphabets

    Hello

    Could someone please help me to get this application working.

    Request to remove row where the value of column contains alphabets.

    DELETE FROM BIN_ITEM WHERE order_nmb LIKE '% [A - Z] % ' | LIKE '% [a - z] %'

    Thank you and best regards,

    Madam.

    SELECT order_nmb FROM BIN_ITEM WHERE regexp_count(order_nmb,'[0-9]') = 0

    ----

    Ramin Hashimzade

  • Script where the zero is not displayed when no value is selected, indicates when a value of zero is selected

    How can I write a calculation script where the zero is not displayed when no value is selected, but when a value field null is selected as part of the zero calculation will show?

    Option 1 has a score of 0 value

    Option 2 has a value of 5 score

    When someone chooses option 1, I want the value 0 to appear at the cell of notation.

    Here is the script that I have so far:

    If (event.value == 0 | event.value == ") event.value =";

    OK, the custom calculation script could be:

    Get the value of the checkbox field

    var v = getField("checkbox1").value;

    Set this field value

    V = Event.Value = "Off"? "" : v;

    Replace "checkbox1" with the actual name of the checkbox.

  • Sales order form, line status code is displayed as "WITHDRAWN". but the same code appears as "AWAITING_SHIPPING" for the same line in the database. can you please explain, where the value in frontend comes? It differs from the flow_status_code in oe_or

    Sales order form, line status code is displayed as "WITHDRAWN". but the same code appears as "AWAITING_SHIPPING" for the same line in the database.

    Where the value in the frontend is filling?

    It differs from the flow_status_code in oe_order_lines_all?

    Thanks for the correction.

    He slipped right out of my mind!

    Here is a detailed explanation of this case:

    Status of orders picked and picked partial

    Kind regards

    Bashar

  • How the LED lights up when a threshold is reached, then turns off only when the value does not reach the threshold for a while?

    Hi, I want to write a program that can turn on the LED when a range of value, this is the threshold and only when the value does not reach the threshold for a period of time, say 5 seconds, then the LED will turn off, otherwise it will remain. How can I achieve this in labview? Can someone help me? Really thanks!

    I assume that you use a while loop to keep the updated value.

    Add a record to offset to your looping it initialize with a U32 (time in ms)

    Add the registry to offset to your loop that keeps the previous value of your bool

    When your reaches the threshold value => the light and set the current time in your shift register.

    In the next iteration of the loop weather check value is still above threshold

    => Y-online previous set to true?

    => Y-online the next iteration

    -Online N => turn switch on and set the current time in your shift register.

    -Online N => subtract the time current less time shift record-online more then 5 seconds?

    => Is => keep turning on

    -Online N => turn given

  • I have rebuilt my laptop Gateway MX6625, did not drive recovery, is went to the gateway web site, all the drivers have worked except the multimedia sound. The gateway was no help, they told her, but the there does not work

    I have rebuilt my laptop Gateway MX6625, did not drive recovery, is went to the gateway web site, all the drivers have worked except the multimedia sound. The gateway was no help, they told her, but the there does not work

    Hello JesusVigo,

    Thank you for visiting the Microsoft answers community.

    Have you tried to use the disk of Windows XP, or Windows Update running default drivers to search for best driver for your sound card?

    Also, I found only 1 driver on your system gateway Web site is located here.

    Hope this helps Chris.H
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • "Bridge shun cal.vi" shunted the setting of the value?

    I copied the "bridge shun cal.vi" LabView example "Acq gauges bridge samples (with calibration) .vi", to include in a strain measuring .vi I'm working.

    My equipment consists of an SCXI-1001 chassis, modules of 1520 and 1314.

    That means the acronym for setting the value of "Shunted"? Resistance value of triage (in ohms, I supouse)?

    And it's less important to me, but think it may be interesting for others: how to choose between the calibration shunt resistance is or B?

    Thank you

    usuario

    Hi user,.

    You are right when you say 'shunt resistance' in VI stands "DAQmx perform Shunt calibration (bridge)" for the value of shunt in ohm resistance. As you can see on page 4 of the SCXI-1314 manual, the two shunt calibration resistors A and B are have a value of 100 kohm. In addition, page 4-28 the SCXI-1520 user manual specifies that they are are in style RN-55 (standard 1/4 W).

    Choosing to respect so shunt calibration resistance A or B, the latter manual mentions on page 3-4 that "shunt calibration switches A and B are parameters of control of software that allow or activate or deactivate the shunt calibration resistors in order to form win calibration." In most cases, you do not explicitly switches shunt calibration check, he makes instead of software driver to automatically adjust them for you during the shunt calibration procedure automated. However, if you want to explicitly control the witches of calibration, you can write an application program which controls the shunt calibration switches.' and returns the user to Chapter 4, principle of operation, for more information.

    I hope this helps.

    Kind regards

  • I need to know where the value Associates

    I am doing a paper for school, I have bee using Microsoft Word, now it tells me that I must go to define Associates and choose one

    place to post my work. Help!  I've never heard of this and I can't find the value Associates.
    Thank you

    Hello

    you bought Word which is part of the Office?

    It does not free

    link below is how to set file associations in Vista

    http://www.TechRepublic.com/article/How-do-i-change-file-extension-associations-in-Windows-Vista/6172036

    Please repost in the forum of Word for Word questions

    http://answers.Microsoft.com/en-us/Office/Forum/Word

  • Number of days where the value &gt; a certain amount

    Hello

    I have a table named named MSR_3423:

    Capture.JPG

    I want to count the number of days where the VALID_VALUE is > to 0.001

    I made this request, but it gives me that result a count of every time that this value has been found in a day:

    select trunc(valid_date), count(*) from MSR_3423 
    where raw_value > 0.001
    and   VALID_DATE IS NOT NULL
    group by trunc(VALID_DATE)
    order by 1
    

    It gives me this result:

    Capture.JPG

    But I want the number of days when this value has been reached. In this example, the result should be: 5 (for 5 days)

    I think there must be a dower to do, but I'm not experienced enough to achieve this goal. Could you help her?

    Thank you.

    You almost have it. Just put another county around your account.

    select count(*) from (
    
      select trunc(valid_date), count(*)
      from MSR_3423
      where raw_value > 0.001
      and  VALID_DATE IS NOT NULL
      group by trunc(VALID_DATE)
    );
    

    or shorter but sometimes confusing

    
      select count(count(*))
      from MSR_3423
      where raw_value > 0.001
      and  VALID_DATE IS NOT NULL
      group by trunc(VALID_DATE) ;
    

    Logic of Alvertos did the same thing. He's just using SEPARATE instead of GROUP BY. But since I do not SEPARATE, I wanted to show a different way.

  • Need help with Javascript to get the value of standard report column

    Hi all

    Apex 3.1 version

    I have a query SQL (editable report) region where I need to do validations using a process of OnDemand and javascript. For this posting, I need to use the serial number and id of this same report line item. The function is called when the serial number is changed. I can get the serial number easily because it is a text field, however, the item id is a standard report column (which actually a text field or hidden gives me a checksum error, long story). How can I get the value of the standard report column to set the value of an element of the Application to use in my process of application as well as the serial number? Here is my code below.
    <script>
    
    function f_ValidateSerial(pThis)
    {
        
      // The row in the table
    
      var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
    
        //alert('Row is '+vRow);
    
    
      // Display the serial number
        //alert('The Serial Number is '+html_GetElement('f21_'+vRow).value);
    
      
     var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=ValidateSerial',0);
     get.add('F101_SERIAL_NUMBER',html_GetElement('f21_'+vRow).value);
     get.add('F101_INVENTORY_ITEM_ID',+html_GetElement(?????+vRow).value);   // Here's where I need to get the item id to set application item!!
     
     gReturn = get.get();
     
    if (gReturn)
        { 
          alert(gReturn);
        }
     
      if(gReturn)
        { 
          html_GetElement('f21_'+vRow).value = '';
        }
               
    }
    </script>

    Hello

    Ok

    Item ID is standard report column.
    If you enter this Expression HTML column

    #ITEM_ID#
    

    I guess that the substitution of column item Id is #ITEM_ID #.

    Now, you have hidden input form that is not submitted.
    Then in JavaScript

    get.add('F101_INVENTORY_ITEM_ID',+html_GetElement('item_id_'+Number(vRow)).value);
    

    Kind regards
    Jari

  • Dialogue boxes not hide all fields, not just those where the value is passed to true

    I hope someone can help me do what I want to happen, to occur if certain boxes are checked in the dialog box

    for now I see on the impression that the checkbox activates the value from false to true, but the OK button is also non-masquage console all my fields, not just those where he transformed the true value. What I'm missing here

    Create a dialog box for the staff to indicate how many of the account owners are in the branch so that the names of show in the signature section
    var Signors =
    {

    result: "Cancel."
    DoDialog: function() {return app.execDialog (this);};
    bChk2:false,
    bChk3:false,
    bChk4:false,
    bChk5:false,
    initialize: function (dialog)
    {
    var dlgInit =
    {
    "Chk2": this.bChk2.
    'Chk3': this.bChk3,
    'Chk4': this.bChk4,
    };
    Dialog.Load (dlgInit);
    },
    commit: function (dialog)
    {
    var oRslt = dialog.store ();
    this.bChk2 = oRslt ["Chk2"];
    this.bChk3 = oRslt ["Chk3"];
    this.bChk4 = oRslt ["Chk4"];
    },
    Description:
    {
    name: "Signors."
    elements:
    [
    {
    type: "display."
    elements:
    [
    {
    type: "display."
    char_height: 10,.
    elements:
    [
    {
    type: 'static_text. "
    item_id: "stat."
    name: "who is there to sign,:
    char_width: 15,.
    alignment: "align_fill",.
    Police: 'dialogue ',.
    },
    {
    type: "display."
    char_width: 8.
    char_height: 8.
    align_children: "align_top."
    elements:
    [
    {
    type: "display."
    char_width: 8.
    char_height: 8.
    elements:
    [
    {
    type: 'check_box. "
    item_id: "Chk2."
    name: "first to file."
    },
    {
    type: 'check_box. "
    item_id: "Chk3."
    name: "Team 1"
    },
    {
    type: 'check_box. "
    item_id: "Chk4."
    name: 'team 2 ',.
    },
    ]
    },

    ]
    },
    ]
    },
    {
    type: "ok_cancel."
    },
    ]
    },
    ]
    }
    };

    made the change of value when checked - allows you to check
    Signors.bChk2 = false;
    Signors.bChk3 = false;
    Signors.bChk4 = false;
    If ("ok" == Signors.DoDialog ())
    {
    If (Signors.bChk2 = true)
    getField("Signor1").hidden = false;
    getField("Staff1").hidden = false;
    getField("Date1").hidden = false;
    getField("Date2").hidden = false;

    If (Signors.bChk3 = true)
    getField("Signor2").hidden = false;
    getField("Staff2").hidden = false;
    getField("Date3").hidden = false;
    getField("Date4").hidden = false;

    If (Signors.bChk4 = true)
    getField("Signor3").hidden = false;
    getField("Staff3").hidden = false;
    getField("Date5").hidden = false;
    getField("Date6").hidden = false;

    Console.println ("Chk2:" + Signors.bChk2);
    Console.println ("Chk3:" + Signors.bChk3);
    Console.println ("Chk4:" + Signors.bChk4);
    Console.println ("Chk5:" + Signors.bChk5);
    console.println if shows bChk... is true or false
    }
    Console.println ("Chk2:" + Signors.bChk2);
    Console.println ("Chk3:" + Signors.bChk3);
    Console.println ("Chk4:" + Signors.bChk4);
    Console.println ("Chk5:" + Signors.bChk5);
    }

    Yes, confirmed values have changed, now show fields based on staff

    principal applicant has been selected


    doWhatIWant: {function (results)}
    If (results [Signors.bChk2] = true)
    getField("Signor1").hidden = false;
    getField("Staff1").hidden = false;
    getField("Date1").hidden = false;
    getField("Date2").hidden = false;

    1 associate has been checked
    If (results [Signors.bChk3] = true)
    getField("Signor2").hidden = false;
    getField("Staff2").hidden = false;
    getField("Date3").hidden = false;
    getField("Date4").hidden = false;

    Associate 2 has been selected
    If (Signors.bChk4 = true)
    getField("Signor3").hidden = false;

    If (Signors.bChk4 = true)
    . Hidden ("surete3") = false;

    If (Signors.bChk4 = true)
    . Hidden ('date.5") = false;

    If (Signors.bChk4 = true)
    . Hidden ('Date6") = false;

    I had to just add a hug to bChk3 database and it worked perfectly. Thank you very much!

  • Req. search criteria to find the values of table in the entire schema.

    Hello

    I have an obligation to identify the value of the particular column that is longer in a table in the schema.
    We have all the Tables system or any other source admin level?

    For example, I have customer id in 18 paintings in our scheme.

    I need like... I want to return to the table of names which are all contains the customer id = 15326.

    If the 7 of 18 table contains the value of the id of customer 15326, then that is my output required that he picks up.
    Don't we have any source to identify this requirement?

    More picture... Customer, CustomerB, ClientC clients client are the tables in the schema that contains the customer id column.

    Here, customer and ClientC contains the value of the identification of customer 15326 folder. So, I need produce the output as the Table names are customer, ClientC.

    I hope, you will understand my requirement.

    Please do the necessary help / advice on that.

    Thank you
    Orahar.

    Re: search string in DB

    Read the link.

    Concerning
    Asif Kabir

  • Activating/Deactivating the ATR records the value does not

    I do changes in the host file of Streaming Full-Duplex and Tx-Streaming to implement a system of TDD using a single antenna.

    I intend to toggle the values of registry ATR by changing 0/RX Enable RF and RF 0/TX Enable between True and False, as shown below.

    I expect the values of RF 0/RX activate read properties FPGA should also switch in same way as implemntented in any separate loop outside the transmission while loop.

    But the value properties FPGA playing stick to a single value and will never switch!

    Should not USRP will cease to emit when RF 0/TX Enable is done wrong?  But I see it's permanently in transmission of data.

    What is proper way to swap the values of registry ATR on the side host?

    Once confimred for system of TDD using access codes alongside host I'll implement tilting sideways FPGA for quick change of antenna.

    Hey wired,

    First, you must put your writing to the FPGA controls in a loop.

    Right now it seems like you're this failover in a loop and play their part in a loop, but never written in a loop.

    Give that a shot and let me know how it goes! Then, based on what you've set in your States of Rx and Tx, must exchange between these configurations.

  • Set/save the value of the local population of LabView development

    Is it possible to set/save value of the inhabitants of Teststand of LabView in the update, so I do not write the value in the variable pane? I can do this to programmatically at runtime with SetProperty, but I want to define them in the update with a VI.

    Thank you

    I use LabViwe 2012 SP1 32 bit and Teststand 2012 SP1

    You have to access the SequenceFile inhabitants and then save it to disk.  I have attached a picture and my code.

    Kind regards

  • Help! Try to update the values of Member - but does not (completely).

    We are trying to resolve a calculation in the middle of the update of business cycle. There is a push to update existing values for an account specific forecast time scenario.

    Essentially, we want to update the value of forecast current account 56400 to 0.33 * ("56100" + "56110" + "56300" + "56310" + "56320").

    The solution is to make sure only rest of the current year, Apr - Dec, updated forecasts to date.

    Currently the rule runs, but handful of values is never get updates - I'm not doing correctly?

    relatively small cube BSO, Account (dense).

    Here is the rule of this task running

    SET CACHE HIGH;

    FIX (& those 'Forecasts', 'the current iteration","F_00000");

    "56400")

    IF (@ISMBR (& NextMonth: "Dec"));

    0.33 * ("56100" + "56110" + "56300" + "56310" + "56320");

    ENDIF ;)

    ENDFIX;

    -followed by a calc all

    I expect to update all occurrences 56400 in the fix above...

    Thanks in advance!

    Himanshu-

    You probably need...

    UPDATECALC OFF SET;

    .. Smart calc or .in there will prevent 'own' blocks to be recalculated.

Maybe you are looking for