Get more value from my table records

Hi Experts,
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> WITH T AS
  2  (
  3  SELECT  1 ID,'1OIKL' VAL,1 FLAG FROM DUAL UNION ALL
  4  SELECT 2,'9IUY',0 FROM DUAL UNION ALL
  5  SELECT 3,'9IUK',0 FROM DUAL UNION ALL
  6  SELECT 4,'9IUS',0 FROM DUAL UNION ALL
  7  SELECT 1,'1OIKL',0 FLAG FROM DUAL
  8  )SELECT * FROM T;

        ID VAL         FLAG
---------- ----- ----------
         1 1OIKL          1
         2 9IUY           0
         3 9IUK           0
         4 9IUS           0
         1 1OIKL          0

SQL>
I need the unique output like VAL result with the biggest FLAG
        ID VAL         FLAG
---------- ----- ----------
         1 1OIKL          1
         2 9IUY           0
         3 9IUK           0
         4 9IUS           0
SQL>
Thank you

Published by: DB-user11904889, March 24, 2010 15:51
Code field included in the values of the table

Try:

SQL> create table T AS
  2  SELECT 1 PK, 1 ID,'1OIKL' VAL,1 FLAG FROM DUAL UNION ALL
  3  SELECT 2,2,'9IUY',0 FROM DUAL UNION ALL
  4  SELECT 3,3,'9IUK',0 FROM DUAL UNION ALL
  5  SELECT 4,4,'9IUS',0 FROM DUAL UNION ALL
  6  SELECT 5,1,'1OIKL',0 FLAG FROM DUAL;

Table created.

SQL> select * from t;

        PK         ID VAL         FLAG
---------- ---------- ----- ----------
         1          1 1OIKL          1
         2          2 9IUY           0
         3          3 9IUK           0
         4          4 9IUS           0
         5          1 1OIKL          0

5 rows selected.

SQL> delete from t t1
  2  where exists ( select null
  3                 from   t t2
  4                 where  t1.val = t2.val
  5                 and    t1.flag < t2.flag
  6               );

1 row deleted.

SQL> select * from t;

        PK         ID VAL         FLAG
---------- ---------- ----- ----------
         1          1 1OIKL          1
         2          2 9IUY           0
         3          3 9IUK           0
         4          4 9IUS           0

4 rows selected.

Tags: Database

Similar Questions

  • Is it possible to see/get the data from the table to a dump file

    I have files dmp generated using expdp on oracle 11 g...

    expdp_schemas_18MAY2013_1.dmp

    expdp_schemas_18MAY2013_2.dmp

    expdp_schemas_18MAY2013_3.dmp

    Can I use a settings file given below to get the data from the table in the file sql or impdp the only option to load the data of table in database.

    VI test1.par

    USERID = "/ as sysdba".

    DIRECTORY = DATA

    dumpfile=expdp_schemas_18MAY2013%S.dmp

    SCHEMAS = USER1, USER2

    LOGFILE = user_dump_data.log

    SQLFILE = user_dump_data. SQL

    and impdp parfile = test1.par.

    No,

    DataPump cannot retrieve a dumpfile data in a flat file.

    Dean

  • To get the value from the user input

    Hi guys,.

    I have a .sql file, I need to get the feedback from the user and date to treat more end passing as a parameter in the procedure

    test. SQL

    Proc_process (p_in = > lv_in p1_in = > lv_in1);

    Once the process described above is then ask the user to change the table with the name of columnn like col_1

    Press on Y to continue or N to exit

    ALTER table T1 add col_1 date;

    I want these operations to be performed when run test.sql

    Hello

    Maybe something like that

    accept option_1 char prompt 'Do you want to alter table T1 ? ( press y to continue n to skip ) : ' default n
    accept option_2 char prompt 'Do you want to alter table T2 ? ( press y to continue n to skip ) : ' default n
    
    prompt alter table T1 : &option_1
    prompt alter table T2 : &option_2
    
    BEGIN
      --
      IF upper('&option_1') = 'Y'
      THEN
          DBMS_OUTPUT.PUT_LINE('>>>>>>>>>>> ALTER TABLE T1');
      END IF;
      --
      IF upper('&option_2') = 'Y'
      THEN
          DBMS_OUTPUT.PUT_LINE('>>>>>>>>>>> ALTER TABLE T2');
      END IF;
    END;
    /
    
    undef option_1
    undef option_2
    
    prompt @d:\temp\test_accept_2.sql
    

    concerning

    Kay

  • How to get the values of the table of the ADF to bean class?

    Hi all

    My 11.1.1.6 Jdev

    Here I do not use BC ADF in my project.  I'll put values in the ADF table with bean.

    In the table, I put a checkbox. When I selected (Checkbox) a few rows in table and submit. In the submit method, I want to get all the values of line checkbox selected in my bean class.

    How can I get the values. ???

    Here my table UI code

    < af:table var = "row" rowBandingInterval = "0" id = "t1" value = "#{pageFlowScope.BinderSolutionsBean.uiBinderProperties} '"

    styleClass = "AFStretchWidth" emptyText = "no record found".

    Binding = "#{pageFlowScope.BinderSolutionsBean.binderTree}" >

    < af:column sortable = "false" headerText = "Script ID" id = 'c4' >

    < af:panelGroupLayout id = "pgl4" >

    < af:selectBooleanCheckbox id = 'sbc1' > < / af:selectBooleanCheckbox >

    < af:spacer width = "5" / >

    < af:outputText value = "#{row.scenarioId}" id = "ot5" / > "

    < / af:panelGroupLayout >

    < / af:column >

    < af:column sortable = "false" headerText = "Quote ID" id = "c1" >

    < af:outputText value = "#{row.quoteId}" id = "ot4" / > "

    < / af:column >

    < af:column sortable = "false" headerText = "NASP ID" id = "c2" >

    < af:outputText value = "#{row.naspId}" id = "ot2" / > "

    < / af:column >

    < af:column sortable = "false" headerText = "GCH ID" id = 'c3' >

    < af:outputText value = "#{row.gchId}" id = "ot3" / > "

    < / af:column >

    < af:column id = "c6" headerText = "Term" >

    < af:outputText value = "#{row.term}" id = "ot9" / > "

    < / af:column >

    < af:column sortable = "false" headerText = "Status" id = "c5" >

    < af:outputText value = "#{row.status}" id = "ot6" / > "

    < / af:column >

    < / af:table >

    follow some above recommendation such as the creation of additional attribute. You will also need the key in your collection, while making the data for your chart.

    You must write a custom selectionListener. On valueChangeEvent of box, get the key of a line and add the line at the bean.

    Maybe it's little help for you

    https://tompeez.WordPress.com/2012/01/22/jdev-custom-SelectionListener-for-viewobjects-in-rangepaging-mode/

    How to get the selected row in a table no-bind ADF

  • How can I get a value from a function from pl/sql by OADBTransaction

    Hi all
    Hope you will be fine.
    as we know, we can get a sequence by this code value:
    Super.Create (AttributeList);
    Transaction OADBTransaction = getOADBTransaction();

    Vendor ID is obtained from the table sequence
    Number supplierId = transaction.getSequenceValue ("FWK_TBX_SUPPLIERS_S");

    My question is how can I get a value in a variable to a pl/sql function:
    the function is defined as follows:
    ******
    create or replace function getNextTrans return varchar2
    is
    Team varchar2 (20);
    Start
    SELECT "CASH". TO_CHAR (SYSDATE, 'DDMMYYYY') | GP_CASH_TRX_SEQ. NEXTVAL FROM DUAL;
    return team;
    end;
    /

    Hey Dina,

    Reference http://www.oraclearea51.com/oracle-technical-articles/oa-framework/229-calling-database-procedures-and-function-from-oaf.html

    Kind regards
    GYAN

  • Getting a value from selectonechoice

    Hello

    I use Jdeveloper 11.1.1.6

    My requirement is as below

    I have a component selected only one option, which displays a list of values.

    The user selects a value from the list of value and clicks the command button, and then the input field should be updated with the

    the value that is selected in the list.

    To do this, I wrote the code (no components company involved / only ADF faces) below

    I am able to get the list of values and post it on my page. For the rest of the game, I am not able to guess.

    I put selectoncechoice partialtriggers for buttons and the text in field

    All I need is the java code for getting the selected value and by attaching it to the text field.

    Can you help or guide me on this...

    Bean:

    The list < SelectItem > tempList.

    {} public void settempList (list < SelectItem > tempList)

    this.tempList = tempList;

    }

    public list < SelectItem > gettempList() {}

    If (tempList == null) {}

    tempList = new ArrayList < SelectItem > ();

    tempList.add (new SelectItem ("t1", "Item 1"));

    tempList.add (new SelectItem ("t2", "Item 2"));

    }

    Return tempList.

    }

    USER INTERFACE:

    <? XML version = "1.0" encoding = "UTF - 8"? >

    " < = xmlns:jsp jsp:root ' http://Java.Sun.com/JSP/page "version ="2.1"xmlns:f =" " http://Java.Sun.com/JSF/core "

    ' xmlns:af = ' http://xmlns.Oracle.com/ADF/faces/rich "> "

    < jsp:directive.page contentType = text/html"; Charset = UTF - 8 "/ >

    < f: view >

    < af:document title = "listPage.jspx" id = "d1" > "

    < af:form id = "f1" >

    < af:panelGroupLayout id = "pgl1" layout = "vertical" halign = "center" >

    < af:spacer width = "10" height = "10" id = "s1" / >

    < af:selectOneChoice label = "Custom List" id = "soc1" contentStyle = "make weight:" BOLD "; color: Green; ">

    < f: selectItems value = "#{Valuesbean.tempList}" id = "si1" / > "

    < / af:selectOneChoice >

    < af:outputText value = "Output text" id = "ot1' partialTriggers ="soc1"/ >

    < af:commandButton text = "Change" id = "ot1' partialTriggers ="soc1"/ >

    < / af:panelGroupLayout >

    < / af:form >

    < / af:document >

    < / f: view >

    < / jsp:root >

    Hello

    If you see:

    You must set a value for the selectOneChoice component. You add a new variable in your beans to use it to store your selectedItem. Then your output text should also reference the same attribute in its value field.

    Try to add in your bean:

    String mySelection;

    public String getMySelection() {}

    return mySelection;

    }

    {} public void setMySelection (String, string)

    mySelection = string;

    }

    value = "#{ValuesBean.mySelection}" label = "Custom List" id = "soc1" contentStyle = "make weight:"BOLD"; color: Green; » >

    and value = "#{ValuesBean.mySelection}" id = "ot1' partialTriggers ="soc1"/ >"

  • How can I update this table with values from another table?

    Hello

    I have a table 'governed '. I want to replace the values in the column "regies.agent" by the value of the column "regies_personnes.id."
    As you can see the tables have a column of common values. IE regies.agent = regies_personnes.nom

    Table 'governed ':
    Insert into 'authorities' (AGENT) values ('Humberdot Alain");
    Insert into 'authorities' (AGENT) values ("Danard Patrick");

    Table 'regies_personnes ':
    Insert into REGIES_PERSONNES (NAME, ID) values ("Humberdot Alain", 1);
    Insert into REGIES_PERSONNES (NAME, ID) values ("Danard Patrick", 2);

    Before having it
    SQL > select agent of authorities;
    Humberdot Alain
    Patrick Danard

    After the update, the result should be
    SQL > select agent of authorities;
    1
    2

    Thank you for your kind reply.

    You can

    update regies r set agent = (select id from regies_persones p where r.agent = p.nom)
      where exists (select id from regies_persones p where r.agent = p.nom)
    
  • Getting a value from a text of entry in backing bean element

    I created a component of entering text on a page where I will enter a number, adjustment of Autosubmit as true. ValueChangeListener property is defined as #{test.displayTable} where displayTable is a method defined in managed bean test.

    Now I know to extract the value entered in the text input component by creating a RichInputText variable in the advanced properties.

    But in case the Advanced property is empty, then how I'll be able to recover the value of it? This is the code. I'm not able to get the value entered in the component. I can not even find any method getvalue for her.
    FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot root = facesContext.getViewRoot();
    RichInputText inputText = (RichInputText) root.findComponent("it1");  // it1 is the id of the input text component
    System.out.println("inputText: "+inputText);
    On the use of my statement, is out getting generated, whereas I had entered in 90.
    inputText: RichInputText[UIXEditableFacesBeanImpl, id=it1]

    Hello

    Always mention your JDev version.

    If you use a valueChangeListener for the field, you can get the value using valueChagedEvent.getNewValue ().

    Arun-

  • I can't get a value from a list of CFDIRECTORY.

    I avoided the madness all these years, but this issue was finally on the brink.  My placement in an institution is in your hands.

    I try to get the name of a specific directory to the list of directories produced by action CFDIRECTORY = 'list '.  But everything I try fails in one way or another.  Bascially, I can't get the value of the structure - even if the code IS the value - because he thinks that the value is meant to be a field or a key.  (The server running CF8).

    These lines of code work fine:

    <!-do and loop through the list of local directories. ->

    < CFSET LocalDirectoryList = "" > "".

    < action CFDIRECTORY = 'list' name = "LocalDirectoryList" TYPE = "dir" directory = "#PathOfLocalFolderToCopyToRemoteFolders #" >

    < CFIF IsDefined("LocalDirectoryList.RecordCount") AND GT LocalDirectoryList.RecordCount '0' >

    < request CFLOOP = "LocalDirectoryList" >

    Now comes the killer.  I want to set a variable whose value is the name of the local current directory - in other words, the value of LocalDirectoryList.Name for each loop the loop.  But if I try to access LocalDirectoryList.Name as a string variable simple, the way I usually for a query string variable-

    < CFSET ThisLocalDirectory = LocalDirectoryList.Name >

    -I get a message "you have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.

    However, if I treat the "LocalDirectoryList.Name" as a structure and try to deconstruct with one of the following conditions.

    (1) < CFSET ThisLocalDirectory = Evaluate (LocalDirectoryList.Name) >

    (2) < CFSET ThisLocalDirectory = ' #Evaluate (LocalDirectoryList.Name) # ">

    (3) < CFSET ThisLocalDirectory = ' #StructFind (LocalDirectoryList, Name) # ">

    (4) < CFSET ThisLocalDirectory = StructFind (LocalDirectoryList, name) >

    (5) < CFSET ThisLocalDirectory = ' #Evaluate (StructFind (LocalDirectoryList, name)) #">".

    I get either "horizons variable is not defined" (for 1 or 2) or "the specified key, backgrounds, does not exist in the structure" (for 3, 4 or 5).

    In this case, the name of this directory is "horizons."  If the value I'm looking for do EXIST in the structure of 'LocalDirectoryList '.  And the code IS that IT is.  But he thinks it is the NAME of a key, rather than the VALUE of the key.

    Note: The addition of the attribute, listInfo = "Name" to the CFDIRECTORY tag limit fields returned, or key, "Name", but LocalDirectoryList.Name is still a structure, and I still get the same results.

    I'll be the next cuckoo in the cuckoo's nest?  Or can you save me and keep me sane?  My fate is in your hands.

    Thank you!

    You don't need the evaluate statement (in fact you probably shouldn't need to use than ever at that time). And inside the loop of your application, you can send all your query without prefix fields.

    When in doubt, empty your query of cfdirectory.

  • getting a value from an XML string

    If I want a loader to load a text file based on XML how I'd get the XML to return a string.


    The first lines of code are my xml file.
    The following code excerpt is my charger of xml.
    The last code snippet is where I want my text file to load.
    In my line of code which is: myLoadVar.load (t.content); How can I get the value of t.content I got an xml file for a file name? I think I should do my xml file returns a string.

    You must add a line of code. I need to see the where it is located, in the lines below.

  • Get unique values from an xml table

    I have an xml file and I would like to create a table of all the unique values of one of its nodes.

    The xml file is called pntxml and the node is pntxml.row.Category where the category is where I would like to create a table of all the unique values.

    I was working through this and would first create an array of all the values in the category in iterating through the xml and pushing these values in a separate table.  When I try to push each entry in a table I get an error or

    TypeError: Error #1009: cannot access a property or method of a null object reference.
    at NAPA_fla::MainTimeline/sortXml()

    var catArray:Array;
    
    function sortXml(event:Event):void{
    for (var i:int = 0; i< pntxml.row.length(); i++){
         tmpCat=pntxml.row[i].Category;
         trace(tmpCat);
            catArray.push(tmpCat);           
    }
    }
    

    Anyone has a suggestion for the best way to get at this problem?

    Thanks in advance,

    Josh

    Your catArray does not exist because you said only she, you have not created an instance of this...

    var catArray:Array = new Array();

  • I'm trying to get a default value from another table. but!!!!!!!!!!!!!!!

    Here is the code

    {} public void setUnitId (numeric value)

    setAttributeInternal (UNITID, value);

    ProductImpl proImp = (ProductImpl) getProduct ();

    setUnitPrice (proImp.getProdPrice ());

    }

    He tells me that it cannot find a getProduct method if it is used to retrieve an instance of the EO product

    I use Jdeveloper 12 c and 12 c DB

    Thank U My Friend it works. There was no relationship between the tables, and after it is created, it works fine.

  • Get the values of default table row when the page loads

    Hello

    I am running JDev 11.1.1.7. We have a page that contains two tables in a relationship of the master / detail of nickname. We can do a real master ADF / detail with view items related because the query for the 2nd table is complex and works best when queries with binding settings. The View object for the 2nd table has a request with 2 link params as it can get in the first table. Thus, when a line is selected in the first table we want to execute ExecuteWithParams on the object from view of the table 2. We do it in the Bean managed for the page in a method that is the selection to the first table listener. It works fine except when the page initially loads, the first line is selected by default. When the default value is selected the selection listener is not triggered.

    I've seen the suggestion of not having a line selected by default when the page loads by removing the value selectedRowKeys on the table. However, we do not want that the 1st row of the table secondary master to be selected by default and we as the table of detail to show the correct corresponding lines.

    Steve

    Steve,

    Not really sure when you say that the 2nd table is complex and may not use the master detail. If the settings link in the parent table, you can set the ViewLink accordingly and it should work, right?

    In any case, if you're after the execution of methods on the loading of the page, you will find the links below.

    If it's a working group, you can add a methodCall as activity by default and UTF, you can use phase listener (if listener server does not).

    https://blogs.Oracle.com/aramamoo/entry/an_epic_question_how_to

    Advice from the Oracle Johny: ADF: how to run the ViewObject with a ViewCriteria on the PageLoad in Application Web ADF

    It will be useful.

    See you soon

    AJ

  • Return multiple values from a table

    Hi there I'm working on a bit of sql that returns values when they exist in a table.
    The code I have returns the correct value when there is an entry in the tbl_studentmodules table, as soon as there is more than one entry in this table it does display no line at all: (.)

    Can someone tell how to return multiple values?

                 select modulename from tbl_modulefeedback
    where 1 = (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 = (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)
    Thanks in advance!

    Ashleigh

    Try this:

    select modulename
    from tbl_modulefeedback
    where 1 <= (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 <= (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)
    

    When you ask questions, please enter CREATE TABLE and INSERT some commands to make it easier to help you.

  • Passing a value from one table to another

    Access database:
    I have 2 tables, table 1 has a field that is a primary key (not indexed, no dups), table 2 has a field that should receive the same number as the table represented in 1.
    The problem is that when the query runs, it gets the MAX (number), but when it is inserted in table 2, all records in table 2 are updated with this number.
    Is there a way to prevent all the records in a table 2 updated and only the most recent file receiving the number in table 1?
    Any ideas?

    This is my query:

    < cftransaction >

    < cfif len (trim (form. GT Time_Spent)) 0 >
    < cfquery "InsertRecord' datasource = name ="NBProdReports">
    Insert Into TblMasterTrans (Time_Spent) Values ('#form.) Time_Spent #')
    < / cfquery >
    < / cfif >

    < cfif len (trim (form. WG Notes)) 0 >
    < cfquery "InsertRecord' datasource = name ="NBProdReports">
    Insert into TblContractInfo_SubMenuTable (Contract_Number, Transaction_Type, Num_Checks_Trans, Notes)
    Values ('#form.) Contract_Number # ',' #form. Trans_Type # ',' #form. Num_Checks_Trans # ',' #form. Notes #')
    < / cfquery >
    < / cfif >

    < name cfquery = "getTask_Number" datasource = "NBProdReports" >
    SELECT MAX (Task_Number) AS theTask_Number
    Of TblMasterTrans
    < / cfquery >

    < name cfquery = "SetTaskNumber" datasource = "NBProdReports" >
    Update TblContractInfo_SubMenuTable
    Set
    Task_Number = #getTask_Number.theTask_Number #.
    Where Task_Number = Null
    < / cfquery >

    < / cftransaction >

    In fact, you could even with impunity with a single query by selecting the Task_Number MAX in the second insert statement.



    Insert Into TblMasterTrans (Time_Spent) Values ('#form.) Time_Spent #')



    Insert into TblContractInfo_SubMenuTable (Task_Number, Contract_Number,
    Transaction_Type, Num_Checks_Trans, Notes)
    SELECT MAX (Task_Number), ' #form. Contract_Number #'.
    ' #form. Trans_Type # ',' #form. Num_Checks_Trans # ',' #form. Note #'
    Of TblMasterTrans

    Phil

Maybe you are looking for

  • Problem with M30x-118, WIFI, WPA, blue screen, Reboot

    -J' have a Toshiba Satellite M30X - 118 1/2 years-J' have all updates MS new beginning of 19.07.05-J' have uptodate Bios Toshiba to the 19.07.05-J' have uptodate Norton Security 2004 beginning of 19.07.05-J' have a WIFI router at home with WPA active

  • Systems running on separate drives, a single machine

    Mac Pro MacPro3, 1Quad-Core Intel Xeon 2.8 GHz. Have currently the system drive running 10.5.8. Now, I wouldn't let it go. I have 3 other sata drives which I bought just formatted and save your work for them. I would like to know if I can install for

  • update of LabVIEW 2011 &amp; 2012

    I currently have installed LabVIEW 2011 and runs OK on my laptop. Each quarter, it seems that we get a new series of DVD from National Instruments. Currently we have sent a package of DVDs for the first quarter of 2012.  Should I just use these DVDs

  • How can I set up a website that charges a small fee when landed on?

    Original title: Mother Mary How can I set up a website that charges a small fee when landed on? I have something to show to the world & I, that the award is not unreasonable [Moved from the community centre of Participation]

  • Security on the C: drive

    Hello everyone. Is it possible for me to get my c drive? I don't want everyone to use it. Thanks in advance.