Select dates that match from same table.

I wish to update a selection of records
where the order_date is the same, and the customer_id is the same.
The update simply need to be to change the order date on both to the lowest date of the two(or how ever many there are for that date).
e.g.
Ship_date / Order_date / customer_id
1-02-01 2-01-01 1
1-02-01 12-01-01 1
12-01-01 1-01-01 2
12-01-01 5-01-01 2
## So above the first 2 records would have the order_date set to the lowest date of the two records.
A self join ?
Not really sure about this, Thanks in advance!

You could try this (not tested):
UPDATE yourTable t1
SET t1.Order_Date = (SELECT min(t2.Order_date)
                           FROM yourTable t2
                           WHERE t2.ship_date = t1.ship_date
                           AND t2.customer_id = t1.customer_id)However this also updates columns that already have the minimum value. Maybe you would like to avoid it, then add some where clause to the Update statement.
Changed because order_date and ship_date needed to be switched.
Message was edited by:
Sven Weller

Similar Messages

  • Reorganize function will not allow "select rows that match"

    I'm trying to sort data in a sheet the same way excel lets you sort by using "filter"
    I'm told that using the Reorganize function will allow me to do this especially if I select the "select rows that match" options.
    The only problem is that that options is grayed out and I can't use it.
    Anybody else have any suggestions or instructions>?
    Thanks

    Make sure you have selected a table

  • How to handle data that got from SAP by Webservice?

    Hi, Gurus.
    I am working on IFbA with ABAP and Adobe LiveCycle Designer.
    I've developed a function module in R/3 system and created webservice, connected the WSDL address to the form. The problem is how can i handle data that got from SAP by Webservice?
    It's Ok if i bind the dataconnection node to the form element, but how can i handle data without binding to the form element? I mean that how can i use the data retrieved from Webserivce in the Javascript, please give me some sample code or script method.
    Thanks.

    Hi Yang,
    If you are using Web Service, then the binding will be done automatically.
    It can't grow automatically, what else should i do to achieve this?
    1.Select the table(make sure you are not selecting subform) in Hierarchy view
    2. Under table select the Row which is having the required fileds for data
    3. In the Binding of that row, check the checkbox "Repeat Row for each item data" and under that check the Min Count which will set the default row **** to 1
    Regards,
    Sachin

  • Combine 2 Queries (from SAME table) into a SINGLE query

    I have this two queries (from SAME table), and want to combine into one SINGLE query, how?
    How can we use CASE WHEN THEN for such situation? 
    Query1:
    SELECT t_inner.*,
    Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min:' AS Productive_Time,
    Floor(t_inner.OperatorDownTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.OperatorDownTime,3600) / 60),2,0) || 'min:' AS OperatorDown_Time
    FROM
    (SELECT SYSTEMTYPE,
    sum(TIME_TEST + TIME_STEP) AS ProductiveTime,
    sum(TIME_IDLE) AS OperatorDownTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-072')
    AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
    AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
    AND MONO != '9999999999'
    GROUP BY SYSTEMTYPE ) t_inner
    Query 2:
    SELECT t_inner.*,
    Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time
    FROM
    (SELECT SYSTEMTYPE,
    sum(TIME_IDLE) AS MachineDownTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-072')
    AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
    AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
    AND MONO = '9999999999'
    GROUP BY SYSTEMTYPE) t_inner
    see http://postimg.org/image/koq87iyyz/  and
    http://postimg.org/image/fv3zxa38n

    with the first query, 
    SELECT t_inner.*,
    Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min' AS Productive_Time
    FROM
    (SELECT SYSTEMTYPE,
    --sum(TIME_TEST) AS TIME_TEST,
    --sum(TIME_SYSTEM) AS TIME_SYSTEM,
    --sum(TIME_STEP) AS TIME_STEP,
    --sum(TIME_IDLE) AS TIME_IDLE,
    sum(TIME_TEST + TIME_STEP) AS ProductiveTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-072')
    AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
    AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
    AND MONO != '9999999999'
    GROUP BY SYSTEMTYPE) t_inner
    it gives output as from 
    http://postimg.org/image/koq87iyyz/
    with the second query,
    SELECT t_inner.*,
    Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time
    FROM
    (SELECT SYSTEMTYPE,
    sum(TIME_IDLE) AS MachineDownTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-072')
    AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
    AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
    AND MONO = '9999999999'
    GROUP BY SYSTEMTYPE) t_inner
    it gives output as from 
    http://postimg.org/image/fv3zxa38n/
    I want to come those 2 queries into a single query, such that it gives both outputs as above. Let me know if you need any other information. thanks.

  • How to delete master data of materials from sap tables

    how to delete master data of materials from sap tables...its needed now.
    i know its not recommended but still we need to do this. give me the best possible approach.
    regards,
    suneetha

    Hi,
    I would suggest you not to write your own code to delete the entries.
    BAPI_MATERIAL_DELETE, this would mark all materials selected for deletion. But still the material would exist in SAP.
    Another solution: Delete a material manually and in another session execute the transaction SM04. This would display the tables which get locked when you do the operation, Then you can write your own code to delete the material numbers from all the related tables.
    Regards
    Subramanian

  • Selecting from Multiple Tables but requiring data to match from a 3rd table

    Hello Everyone,
    I'm having alot of trouble with this select
    I have three tables:
    prod_poured, conc_test, and cyl_breakTo put together my report, I need to grab this data:
    cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"and I need it to grab all data in those two tables when one column in the prod_poured table meets a certain condition
    This is what I have so far:
    select cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"
    from conc_test inner join cyl_break on conc_test.pour_no = cyl_break.pour_no, prod_poured
    where conc_test.pour_no = prod_poured.test_id and prod_poured.job_no = '9-12-821';It gives me the right results but wayyy too many of them so obviously I've got something wrong.
    the results it gives are this:
    Pour Number     Cylinder ID     Pour Date     Mix #     Ambient Temperature     Concrete Temperature     Air %     Break Date     Age (Days)     Specified Strength     Specimen Strength
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6The results I need it to give are this:
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49As you can see my query provides the right results, just way too many of them. I only need to have one result per cylinder id.
    I can't seem to wrap my mind around this one and if somebody could put together a proper select based on what I need that would be extremely helpful. If you need any more data to provide help just ask and I'll paste it.
    Thanks,
    dtr
    Edited by: dtr on Apr 26, 2010 11:12 AM

    dtr wrote:
    Hi,
    Here are the create table statements:
    create table conc_test
    (p_date date, job_no varchar, mix varchar, pour_no varchar, amb_t varchar, conc_t varchar, slump varchar, air varchar, density varchar, cyl_cast_time timestamp)
    create table cyl_break
    (job_no varchar, pour_no varchar, cyl_id varchar, pour_d varchar, break_d varchar, age varchar, spec_str varchar, str varchar, mix);
    create table prod_poured
    (prod_id varchar, pour_id varchar, test_id varchar);
    Great!
    Don't forget to post the INSERT statements, and the output from that data (if it is different from what you posted in your first message).
    Basically I need to pull the data I showed above out of conc_test and cyl_break, but only data that has the proper job_number which is retrieved from the prod_poured table. The prod_poured test_id for everything that has the proper prod_poured job_no So an IN-subquery, like Sudhakar and I suggested, should work.
    What was the problem when you tried them? Post the query you ran, even if you just copied and pasted it from this thread: there may have be an editing error.
    prod_poured test_id is the same thing as conc_test pour_no and cyl_break pour_noExactly! But that doesn't answer the question: Is that value unique in all the tables? If not, in which tables can it be duplicated?

  • Creating View based on Current and previous data from same table

    I am trying to create a view based on a table called “my_companies”. The table has following columns: “company_id”, “start_date”, “product_type_code”, “partner_id”
    The main purpose of this view is to obtain previous company_id’s associated with a particular “partner_id“and “product_type_code”. So basically, I’m looking to create an extra column, say “prev_company_id” in the view along with all the other columns. The “previous” data can be obtained depending on the “start_date”. I’m not able to write a query successfully to do this.
    Can anyone help? Thanks in advance.

    Hi,
    Whenver you have a question, it helps to post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data
    (4) Your best attempt so far
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    Formatted tabular output is okay for (3). Type before and after the tabular text, to preserve spacing.  The sample results should include any special cases that you foresee, such as one company having many previous companies, or vice-versa.
    It sounds like might need a +self-join+, where you have two copies of the same table, as if the current companies were in one table and the previous companies were in another, even though they are all actually in the same table.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Data not updating in Metadata with Select options that come from a view

    Hi All,
    I have a similar problem.
    I have a view called "contractnumberview" created in UCM that gets a "contractnumber" from database table called "Contracts"
    The view is used as options list for a metadata called "xContractNumber".
    The data is inserted in the "Contracts" table from an ADF Application.
    Problem:
    After a new contract number is inserted into the Contracts table from the adf application, the new contract number does not show up in the check-in form drop down of the xContractNumber metadata field.
    If i open the "contractnumberview" from configuration manager, the new contractnumber is listed there.
    Is there anything special required to be done so that the contract number is published in the check-in forms also.
    Thanks
    Amit

    Hi Everybody,
    I Discovered how to ADD or Delete intens in java class, but now would like to update Title value.
    The code is:
                List fields = new ArrayList(2);
                fields.add(new DataResultSet.Field("dDocName"));
                fields.add(new DataResultSet.Field("dDocTitle"));
                DataResultSet resultSetNovo = new DataResultSetImpl();
                resultSetNovo.setFields(fields);
                List leilaoRow = new ArrayList(2);
                leilaoRow.add("SOME_EXISTENT_ID");
                leilaoRow.add("SOME_EXISTENT_DESCRIPTION");
                resultSetNovo.addRow(leilaoRow);
                IdcClient idcClient1 = manager.createClient ("idc://host:port");
                IdcContext userContext1 = new IdcContext ("user","password");
                HdaBinderSerializer serializer1 = new HdaBinderSerializer ("UTF-8", idcClient1.getDataFactory ());
                DataBinder dataBinder1 = idcClient1.createBinder();
                dataBinder1.putLocal("IdcService", "EDIT_SCHEMA_VIEW_VALUES");
                dataBinder1.putLocal("schViewName", "C_LISTA_LEILOES");
                //add/update/delete
                dataBinder1.putLocal("editViewValueAction", "update");
                dataBinder1.addResultSet("LeiloesCadastrados", resultSetNovo);
                serializer1.serializeBinder (System.out, dataBinder1);
                ServiceResponse response1 = idcClient1.sendRequest(userContext1,dataBinder1);
                DataBinder responseData1 = response1.getResponseAsBinder();
    The error is:
    Unable to edit view values for view 'C_LISTA_LEILOES'. The key CCEE_54321 could not be added due to a primary key constraint violation in the LeiloesCadastrados table.
    And the consoel messages during the process is:
    @Properties LocalData
    IdcService=EDIT_SCHEMA_VIEW_VALUES
    UserTimeZone=UTC
    UserDateFormat=iso8601
    schViewName=C_LISTA_LEILOES
    editViewValueAction=update
    @end
    @ResultSet LeiloesCadastrados
    2
    dDocName
    dDocTitle
    CCEE_54321
    SOME_DIFERENT_TEST
    @end
    Im my table the column dDocName is the primary key and I´m trying to change only the dDocTitle column
    Any help will be appreciated
    Thanks for everybody.
    LCruz

  • Storing Data in Context from a table (multiple selection)

    Hi,
    I have created a node called cauverynode, which contains cauName and cauClient as its attribute. I have bound that node with the table. Now i have to store the selected clients into a context. How can i do that? Please help me out. i am unable to store the clients in a string context. Kindly solve it. Below is the code, which will store the selected item and put into a string variable.
    public void supplyCauveryNode(IPrivateSampleComponent.ICauveryNodeNode node, IPrivateSampleComponent.IContextElement parentElement)
    //@@begin supplyCauveryNode(IWDNode,IWDNodeElement)
    IPublicSampleComponent.ICauveryNodeNode cauNode =
    wdContext.nodeCauveryNode();
    ArrayList selectedcauClients = new ArrayList(cauNode.size());
    for (int i = 0, n = cauNode.size(); i < n; ++i) {
    if (cauNode.isMultiSelected(i) || i == cauNode.getLeadSelection())
    selectedcauClients.add(cauNode.getElementAt(i));
    String strSelcaucli = null;
    for (int i = 0, n = selectedcauClients.size(); i < n; i++) {
    strSelcaucli = strSelcaucli + selectedcauClients.get(i);
    wdContext.currentContextElement().setStrCauveryClient(strSelcaucli);
    //@@end
    Multiple selected data is been stored in this selectedcauClients arraylist, which is not working.  Kindly help  me out.
    Thanks & Regards,
    Dhana

    What is the following code supposed to do?
    String strSelcaucli = null;
    for (int ix = 0, n = selectedcauClients.size(); ix < n; ix++) {
    strSelcaucli = strSelcaucli + selectedcauClients.get(ix);
    wdContext.currentContextElement().setStrCauveryClient(strSelcaucli);
    I guess you want to create a string containing the names(?) of all selected elements.
    Then you should use something like
    StringBuffer sb = new StringBuffer();
    for (Iterator it = selectedcauClients.iterator(); it.hasNext(); )
      ICauveryNodeElement e = (ICauveryNodeElement) it.next();
      sb.append(e.getName());
      if ( it.hasNext() ) sb.append(",");
    String csv = sb.toString();
    This gives you a comma-separated list of the names of the selected elements.
    Armin

  • How to convert data when transferring from one table to another

    I have two tables and these are the structure of the tables
    create table E1(
    ID NUMBER
    ,NAME VARCHAR2(30)
    , DESIGNATION VARCHAR2(30)
    ,GENDER VARCHAR2(10));
    create table E2(
    ID NUMBER
    ,NAME VARCHAR2(30)
    , DESIGNATION VARCHAR2(3)
    ,GENDER NUMBER); Now I want to transfer records from one table to another using a master tables where data are compared because the datatypes in tables are different
    The first one is a gender table to match the gender and convert
    create table Gender(
    E1 varchar2(10),
    E2 number);The second is for the designation
    create table Designation(
    E1 varchar2(30),
    E2 varchar2(3);How to match and convert the data so that it can be transfered.

    Peeyush wrote:
    Can we do it with the help of a cursor.
    All SQL executed by the database are parsed as cursors and executed as cursors.
    I mean I have to insert data in bulk and I want to use cursor for it.The read and write (select and insert) are done by the SQL engine. The read part reads data and passes it to the write part that inserts the data.
    Now why would using PL/SQL and bulk processing make this faster? It will reside in-between the read part and the write part being done by the SQL engine.
    So the SQL engine reads the data. This then travels all the way to the PL/SQL engine as a bulk collect. PL./SQL then issues an insert (the write part to be done by the SQL engine). And now this very same data travels all the way from the PL/SQL engine to the SQL engine for insertion.
    So just how is this approach, where you add extra travel time to data, faster?
    and i want to commit the transaction after every 50 recordsWhy? What makes you think this is better? What makes you think you have a problem with not committing every 50 rows?

  • Report with multiple COUNT columns with counts from same table

    I am new to discoverer so I am a bit lost.
    I am working to create a report to show usage data from the eBusiness Knowledge Base. I have the query written in SQL using subqueries that is in the format:
    Solution Number | Soultion Title | Solution Views | Positive Feedback | Negative Feedback
    12345 ___________ Title ________ 345 ____________ 98 _______________ 34
    The 'Views', 'Positive' and 'Negative' entries are stored in the same table so i am doing a count where setid=setid and usedtype=VS, then counting where usedtype=PF and usedtype=NF
    In discoverer I can get the solution number, title and ONE of the totals but I can't seem to figure out how to get a COUNT for three different things from the same table in columns on the same row.
    When I go to edit sheet -> select items once I select the COUNT option for the UsedType column in the table CS_KB_SET_USED_HISTS I can't select it again. I also have found now way to add a column based on an entered query.
    If anyone could help it would be much appreciated.
    Thanks
    Edited by: Toolman21 on Dec 2, 2010 2:17 PM
    added ______ to correct spacing.

    Hi,
    You can separate the column by using a case or decode.
    for example create 2 calculations:
    case
    when usedtype='PF'
    then <you original column> --- the one contain them both
    else 0
    end
    case
    when usedtype='NF'
    then <you original column> --- the one contain them both
    else 0
    end
    after that you can create the count aggregation over those.
    Tamir

  • Parent/child records from same table

    I want to create a query that is a union such that the 2nd resultset is based on the 1st resultset. I have a table that has parent/child records in the same table.
    Table: EVENTS
    EVENT_ID
    PARENT_EVENT_ID
    CREATED_DATE
    (other columns)
    if PARENT_EVENT_ID is null then it is a parent record, else it is a child record. I want to select all parent records then union them with all the associated child records...something like this:
    select * from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null -- All parents
    union
    select * from EVENTS where PARENT_EVENT_ID in (select EVENT_ID from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null) -- include any children of parents selected from above
    This works but it's kind of ugly, I want to avoid using the sub-select in the 2nd because it is a repeat of the 1st statement, is there a way to alias the first statement and just refer to it in the 2nd query?

    Hi,
    kev374 wrote:
    Thanks, one question...
    I did a test and it seems the child rows have to also satisfy the parent row's where clause, take this example:
    EVENT_ID|PARENT_EVENT_ID|CREATED_DATE
    2438 | (null) | April 9 2013
    2439 | 2438 | April 11 2013
    2440 | 2438 | April 11 2013
    select * from EVENTS where CREATED_DATE < sysdate - 9
    start with EVENT_ID = 2438
    connect by PARENT_EVENT_ID = prior EVENT_IDSo you've changed the condition about only wanting roots and their children, and now you want descendants at all levels.
    This pulls in record #2438 (per the sysdate - 9 condition) but 2439 and 2440 are not connected. Is there a way to supress the where clause evaluation for the child records? I just want to pull ALL child records associated with the parent and only want to do the date check on the parent.Since the roots (the only rows you want to exclude) have LEVEL=1, you can get the results you requested like this:
    WHERE   created_date  < SYSDATE - 9
    OR      LEVEL         > 1However, since you're not ruling out the grandchildren and great-grandchildren any more, why wouldn't you just say:
    SELECT  *
    FROM    events
    WHERE   created_date     < SYSDATE - 9
    OR      parent_event_id  IS NOT NULL;?
    CONNECT BY is slow. Don't use it if you don't need it.
    If you x-reference my original query:
    select * from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null -- All parents
    union
    select * from EVENTS where PARENT_EVENT_ID in (select EVENT_ID from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null) -- include any children of parents selected from above
    The 2nd select does not apply the created_date < sysdate - 90 on the children but rather pulls in all related children :)Sorry; my mistake. That's what happens when you don't post sample data, and desired results; people can't test their solutions and find mistakes like that.

  • Query to select values that match multiple ranges

    Hi,
    Oracle 10g.
    I have a table POINTS(ID INTEGER, CLASS VARCHAR2(15), CUMUL NUMBER(2,1), ...).
    In my application (APEX application), I show a list of point classes, order by cumul.
    SELECT CLASS FROM POINTS ORDER BY CUMUL;Then user can choose some range of point classes (CUMUL is not shown in the application, it is just for the example) :
    CUMUL     CLASS
    12.2     31458     <- 
    13.4     5S84     <-     range 1 
    13.6     78PPH     <- 
    15.0     3R594     <- 
    15.1     ZB452 
    15.5     54IO 
    17.6     21GFD 
    19.2     A54VV     <- 
    19.9     IC112     <-     range 2 
    20.8     158RC9     <- 
    21.3     G4G5 
    23.0     V22     <-     range 3For each range, I store only first and last classes selected by a user, in a table USER_SELECTION(ID, ID_USER, FROM_CLASS, TO_CLASS), so using the example above it would give :
    ID     ID_USER          FROM_CLASS     TO_CLASS 
    1     12          31458          3R594 
    2     12          A54VV          158RC9 
    3     12          V22          V22
    ...     ...          ...          ...The problem is that in a query, I need to return all points selected by a user, and I really don't know how to achieve that without too much work... :
    SELECT *
    FROM POINTS
    WHERE USER_ID=12
    AND CLASS IN ( *???* );
    Any help would be much appreciated.
    Yann.

    It's not exactly clear what data is in what tables etc. but perhaps something like this...
    select user_selection.id, points.*
    from points, user_selection
    where user_selection.user_id = 12
    and   points.cumul between
          (select cumul from points where class = user_selection.class1)
          and
          (select cumul from points where class = user_selection.class2)
    order by user_select.id, points.cumul

  • How to select all the colomns_names from a table, with their datatypes ..

    hi :)
    i would like to know, how to select in SQL all the columns names from a table with their datatypes so that i get something like this :
    Table 1 : table_name
    the column ID has the Datatype NUMBER
    the column name has the Datatype Varchar2
    Table 2 : table_name
    the column check has the Datatype NUMBER
    the column air has the Datatype Varchar2
    and that has to be for all the tables that i own ! ..
    P. S : i m trying to do this with java, so it s would be enough if you just tell me how to select all the tables_names with all their colums_names and with all their datatypes ! ..
    thank you :)
    i ve heard it can be done with USER_TABLES .. but i have no idea how :( ..
    Edited by: user8865125 on 17.05.2011 12:22

    Hi,
    The data dictionary view USER_TAB_COLUMNS has one row for every column in every table in your schema. The columns TABLE_NAME, COLUMN_NAME and DATA_TYPE have all the information you need.
    Another data dictionary view, USER_TABLES, may be useful, too. It has one row pre table.

  • Select query for fetching from 3 tables.

    Can we have a single Select query for fetching same fields (kappl,kschl,vkorg,vtweg,spart,kunwe,datbi,knuma,datab,knumh)
    from 3 tables >> KOTE707,KOTE708 and KOTE709 into an internal table for a particular KUNNR?
    Regards,
    Shashank.

    Hi,
    If you have kunnr field in all the 3 tables then it is possible. use inner join as below
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
                p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
             fldate TYPE sflight-fldate,
             carrname TYPE scarr-carrname,
             connid   TYPE spfli-connid,
           END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
                   WITH UNIQUE KEY fldate carrname connid.
    SELECT c~carrname p~connid f~fldate
           INTO CORRESPONDING FIELDS OF TABLE itab
           FROM ( ( scarr AS c
             INNER JOIN spfli AS p ON p~carrid   = c~carrid
                                  AND p~cityfrom = p_cityfr
                                  AND p~cityto   = p_cityto )
             INNER JOIN sflight AS f ON f~carrid = p~carrid
                                    AND f~connid = p~connid ).
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    <b>Reward Points if this helps,</b>
    Satish

Maybe you are looking for