query SQL fetch high two recordings for a given column

Hello world

I have to extract the first two records, I'm actually brings together a few tables and retrieve data

my query:

Select rst.tl_id tl, xwlst.well_id

R_tool pay RST,

extended x_class

r_class rsc,

x_tool xwlst

where rst.r_tool_id = xstc.r_tool_id

and rsc.r_class_id = xstc.r_class_id

and xwlst.r_tool_id = rst.r_tool_id

Rst.r_well_log_service_tool_id group, xwlst.well_log_id

max (rsc.precedence) desc order

the data are:

TL_IDWELL_ID
86405061127
48015061127
86365061127
25635061128
66125061128
25385061128
8435061128
137545061129
125375061129
26095061129
8575061129

I want two recordings of songs for a well_id based on the above data

TL_ID WELL_ID
86405061127
48015061127
25635061128
66125061128
137545061129
12537

5061129

Please advise on this.

Hanks,

Hello

Here's a way to do it:

WITH got_r_num AS

(

Select rst.tl_id - no need to give an identical alias column name

xwlst.well_id

Rank () OVER (PARTITION BY xwlst.well_id

ORDER OF MAX (rsc.precedence) / / DESC

) AS r_num

R_tool pay RST,

extended x_class

r_class rsc,

x_tool xwlst

where rst.r_tool_id = xstc.r_tool_id

and rsc.r_class_id = xstc.r_class_id

and xwlst.r_tool_id = rst.r_tool_id

Rst.r_well_log_service_tool_id group, xwlst.well_log_id

)

SELECT tl, well_id

OF got_r_num

WHERE r_num<=>

;

If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

What happens if there is a tie, and lines 3 (or more) have equal claims to be in the top 2?  You may need to add expressions of tiebreaker to the analytical ORDER BY clause or use ROW_NUMBER instead of RANK.  If it is possible in your application, then include an example when you post the CREATE TABLE and INSERT statements and publish the accurate results you want from these data.

Tags: Database

Similar Questions

  • Report of two lines for a given element

    All,

    I need to generate a report that will list the credits on a single line and debits on the next line. A bit like the following:

    Account Name___Amount
    Cash ................. 1000.00... (this line would reflect positive entries or deposits)
    Cash .................... 20.00-... (this line would reflect the negative entries, or withdrawals)

    Is there an easy way to do something like that?

    We lack the Discoverer 10g Desktop edition.

    Thank you

    Gary F.

    Hello

    You will need a generator line set up in Disco administrator to add lines to your report. The LearnDiscoverer blog (http://learndiscoverer.blogspot.com/2008/10/row-generators.html) has some details. You will need such as:

    -case when n = 1 and amount > 0 then amount when n = 2 and amount< 0="" then="" amount="">

    Rod West

  • SQL query to retrieve a single record for each employee of the following table?

    Hi all

    Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.

    CREATE TABLE xxc_contact)

    empnum NUMBER,

    alternatecontact VARCHAR2 (100),

    relationship VARCHAR2 (10),

    phtype VARCHAR2 (10),

    Phone NUMBER

    );

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)

    expected result:

    EmpNum AlternateContact Relationship PhType Phone       

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Thanks in advance.

    994122 wrote:

    Thank you all, that I got a result

    http://www.orafaq.com/Forum/m/620305/#msg_620305

    By Lalit Kumar B...

    Specifically, the two simple solutions provided were:

    1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).

    SQL > column alternatecontact format A20;

    SQL >

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))

    3 FROM xxc_contact one)

    4. WHEN r = 1

    /

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

    ---------- -------------------- ---------- ---------- ----------

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)

    3 WHERE phone = rn

    4.

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

    ---------- -------------------- ---------- ---------- ----------

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Kind regards

    Lalit

  • Two updates - for "SQL Server 2005 Service Pack 3 'and 'Power Poin 2007", throwing errors when installing Code FF Code 80070663

    Original title: two updates - for "SQL Server 2005 Service Pack 3 'and 'Power Poin 2007", throwing errors during installation

    For several months, one day each on ' Windows Vista Bussiness "and"MS Office Professional 2007' install.

    Relevant updates are:-

    1 security Update for SQL Server 2005 Service Pack 3 (KB2494113)

    2 update for Microsoft Office PowerPoint 2007 (KB2535818)

    The lifted message when the update is "patch installer has stopped working".

    Finally, the "errors:" are: -.

    Code FF  Windows Update has encountered an unknown error

    Code 80070663  Windows Update has encountered an unknown error

    I tried nmerous solutions suggested on the forums but nothing helped.

    Please suggest what you please!

    Hello

    Have what troubleshooting steps you tried?

    Answer to the above question could help us by providing the best troubleshooting steps.
    However, visit the link below to download and install the update of security for Microsoft Office PowerPoint 2007 (KB2535818) update.
    http://www.Microsoft.com/download/en/details.aspx?ID=24723

  • By comparing the two tables for the integrity of the data

    Hi all
    I need to compare two tables for the integrity of the data through the SQL query.

    If you need to compare all the columns of t1 to t2:

    (SELECT * FROM t1
    MINUS
    SELECT * FROM t2)
    UNION ALL
    (SELECT * FROM t2
    MINUS
    SELECT * FROM t1);
    

    Kind regards
    Ankit Rouault
    http://theoraclelog.blogspot.in

  • Query SQL Report with condition (multiple settings) at the point of the apex?

    Hi all

    I have a small problem and cannot find a solution.

    I need to create reports based on a query, SQL or I.R. Nothing hard here.
    I need to add the WHERE clause dynamically with javascript to an element of the Apex.
    Even once is not very difficult. I set the agenda of the Summit, put my query like this "SELECT * FROM MYTAB WHERE COL1 =: P1_SEARCH" then I call the page by setting the P1_SEARCH value. For example, COL1 is rowid. It works very well.

    But here's my problem. Consider that P1_SEARCH contains several ROWID, and I don't know the number of these values,
    (no I don't create a large number of items and create a query with so much GOLD!), I would sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (: P1_SEARCH) with something like: ROWID1, ROWID2 in P1_SEARCH."

    I also tried: 'ROWID1, ROWID2' and 'ROWID1', 'ROWID2 '.
    but I can't get anything else than the mistake of filter. It works with a value, but as soon as there are two values or more, it seems that the Apex is unable to read the string.


    How can I do it please?

    Thanks for your help.

    Max

    mnoscars wrote:

    But here's my problem. Consider that P1_SEARCH contains several ROWID, and I don't know the number of these values,
    (no I don't create a large number of items and create a query with so much GOLD!), I would sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (: P1_SEARCH) with something like: ROWID1, ROWID2 in P1_SEARCH."

    I also tried: 'ROWID1, ROWID2' and 'ROWID1', 'ROWID2 '.
    but I can't get anything else than the mistake of filter. It works with a value, but as soon as there are two values or more, it seems that the Apex is unable to read the string.

    For a standard report, see + {message identifier: = 9609120} +.

    For an IR - and improve safety by avoiding the risk of SQL Injection, use a collection containing the values in a column instead of a CSV list:
    {code}
    SELECT * FROM MYTAB WHERE ROWID IN (SELECT c001 FROM apex_collections WHERE collection_name = "P1_SEARCH")
    {code}
    (Please close duplicate threads spawned by your original question.)

  • Query SQL vs Apex_collection

    good day, which is faster to recover data, to create a collection of query b, then call the collection in a region of reports or sql query normal area of reports?

    Suppose the table has 1,000 records and paging is fixed to 10 records. Take to fetch each record takes 1 millsec and 1 dry mill display

    Approach 1
    Normal in the region of SQL query
    * 1). * Gets 10 records and displays = > 1 * 10 mil for extraction, 1 * 10 mil for display => total 20 mil

    Approach 2
    Report using the Collection
    (* 1) * create a Collection of query => (extract all records: 1000, create the collection add each record to collection) => 1 * 1000 mill to fetch, couple of mils for treatment of collections
    (* 2) * report of the collection => same time as any approach 1 + more time - variable SQL query doesnot use one of the original table column index since its based on a collection

    The answer is not obvious?

  • Use of the function of group in orcl:query sql - database - urgent

    All,

    Version: 10.1.3.4
    Two requirements for me:
    1. I want to use the sum function in orcl:query - database. How to use it?

    For ex: I tried the following

    < xsl: value-of select ='orcl:query - database ("select sum of emp", false (), false (), "jdbc/DB1")'/ >
    I got the following error
    oracle.xml.sql.OracleXMLSQLException: character ')' is not allowed in an XML tag name.
    When I tried without the sum function, it works fine
    2. I used the same table, but without the sum works as below

    < xsl: value-of select ='orcl:query - database ("select emp salary", false (), false (), "jdbc/DB1")'/ >
    This time, it returns the first salary employees! I don't understand this logic. I expected, either the query returns all rows, otherwise it throws the error, but none of them were real!

    Can pls someone explain what behavior? I want your answer to both queries!

    I am currently in a project where I work in the same scenario, so guru of let me know as soon as POSSIBLE.

    Thank you
    Sen

    Hello

    have you tried to put an alias something like select Sum Total emp

  • Where the conditional, or PL/SQL block as a source for an interactive report?

    I have this situation: my app's main screen displays a list of documents. For now, there must be a quick way to 'security' integrated, so that administrators can see all documents, but only other users can see what documents, they created (connection of the creator is stored in the table of documents). In the future we will use probably VPD to enforce certain rules, but for the moment we need a quick solution.

    So I stored administrators in a separate table. Now I want the interactive Act report on the homepage as follows:
    -If an admin is connected, it must have this query: select field 1, 2, 3 area in documents
    -For all other users: select the field 1, 2, area 3 documents where creator =: app_user

    Is this possible in a single interactive report? I could do two reports with different queries, and make conditional depending on who is connected, but this gives me two interactive reports to maintain. Is it possible to use a PL/SQL block as a source for the report? I tried, but I get a syntax error. Is it possible to do where proviso on somehow?

    Hello

    Install the demo application to your workspace:
    Home > create an Application and select Demo Application.

    Check page 1 interactive report. This should give idea how.

    BR, Jari

  • Validation of a region defined as a QUERY SQL type (updated report)

    Hello

    I am trying to perform validation on a region defined as type of QUERY SQL (editable report). The report has two columns.
    One of the columns is a Select list and I want to make sure that the user can select the same value twice
    in the report. For example, if the selection list has 5 values A, B, C, D, E, I don't want a user to be able to select
    B twice in the report. Will it use javascript to perform validation? If Yes, could someone provide some guidance on
    where to embed the javascript? Are there other alternatives than javascript? I create an element that came from a sql query
    counts the number of lines where the value of the column is the same. I then used the item in my validation logic. The problem with this logic
    is that a user can enter the same value and it is not until the 3rd attempt to select the same value that the validation works using the number of lines which is why I think that I need to somehow capture the value of the selection list when a user selects and then compare it to what is already in the database column Select.

    I hope that my question and explanations are clear.

    Thanks in advance for your help,

    Michael

    Hello

    This can be managed using javascript or a validation of the page. Here is an example of use of javascript: [http://htmldb.oracle.com/pls/otn/f?p=267:7]

    To do this, I have:

    1 - a model of button which does not send the page but just runs javascript. The model will depend on your theme, but should include:

    <a href="#BUTTON_ATTRIBUTES#">#LABEL#</a>
    

    If #BUTTON_ATTRIBUTES # appears on the template, delete it as we need it only once. You must create a new button model based on a copy of your existing across models, shared components. Normally, he would show href = "" #LINK # "-we do not want that this would become doSubmit('buttonname')." If your model does not use tags for buttons, you might need to create one from scratch.

    2 - I have updated the button on my page to use this template and then assign the setting button attributes:

    javascript:check();
    

    3. in the header of the HTML page, I added:

    <script type="text/javascript">
    function check()
    {
     var e = 0;
     var f = document.getElementsByName("f02");
     var k1;
     var k2;
     var v1;
     var v2;
     if (f)
     {
      for (k1 = 0; k1 < (f.length - 1); k1++)
      {
       v1 = f[k1].value;
       for (k2 = (k1 + 1); k2 < f.length; k2++)
       {
        v2 = f[k2].value;
        if (v1 == v2)
        {
         e = 1;
        }
       }
      }
     }
     if (e > 0)
     {
      alert("Duplicates found!");
     }
     else
     {
      doSubmit("SUBMIT");
     }
    }
    </script>
    

    In this example, SUBMIT is the name of the button and "f02" is the name attribute of the select list items that we want to check - change these needs by your page.

    Now, when the Submit button is clicked, instead of directly submit the page, the javascript function is called. This function loops through each selection list and gets its value. Then, he compared it to the remaining items. If there is a match, the e flag is set to 1. After all the items have been verified, if e is not 0, then a message appears. Otherwise, the page is sent.

    Andy

  • SQL Fetch data recordset provides incomplete results

    I use the code below to return data to a SQL database. However, varying all the elements in the array are empty except for the last column. In aid of "Database of Variant data" does not help (all but the last column is always empty). All the columns are correctly sent 'Column of the list' to 'pick the data. " The SQL query is a simple "Select" query that should return all data in the table. The SQL table is set up with all the fields in the form of text. Yes, there are data in the table. What else could be wrong?

    I'm using LabVIEW 2009 and the kit of connectivity of database and MS SQL Server 2005 Management Studio Express.


  • Parse Hard &amp; Soft Parse for a given SQL?

    Hi all

    I need to know which of these is a hard and soft analysis for a given Sql. What I think is the 'charges' and 'invalidation' indicates if a cursor is invalidated and gets reloaded, which allows us to check if a call analysis becomes hard analysis.

    Confusion here is should "Disk reads" value nonzero means hard analysis regardless of the 'load' and 'invalidation' and 'Disc bed' zero value means soft parse?

    SELECT a.SQL_ID, a.INSTANCE_NUMBER, a.SNAP_ID,
      TO_CHAR(b.END_INTERVAL_TIME, 'DD-MON-YYYY HH24:MI') snap_time,
      a.PLAN_HASH_VALUE,
            ROUND(a.ELAPSED_TIME_DELTA/1000000) TOTAL_EXECUTION_TIME_SEC,
            ROUND(a.CPU_TIME_DELTA/1000000)    cpu_seconds,
            a.ROWS_PROCESSED_DELTA    rows_processed,
            a.BUFFER_GETS_DELTA      buffer_gets,
            a.DISK_READS_DELTA      disk_reads,
            a.EXECUTIONS_DELTA      executions,
            a.PARSE_CALLS_DELTA    parses,
      a.VERSION_COUNT             version_count,
            a.LOADS_TOTAL               loads_total,
            a.INVALIDATIONS_TOTAL       invalidations_total
    FROM DBA_HIST_SQLSTAT a, DBA_HIST_SNAPSHOT b
    WHERE a.SNAP_ID = b.SNAP_ID and a.INSTANCE_NUMBER=b.INSTANCE_NUMBER
    AND a.INSTANCE_NUMBER=1 AND a.SQL_ID='bsraj0u9r9d3w'
    ORDER BY a.SNAP_ID desc;
    
                                                                 TOTAL
                  Instance      Snap Snap                    EXECUTION     CPU                    Buffer     Disk                   version loads invalidations
    Sql Id          Number        Id Time                    TIME(Sec) Seconds     Rows             Gets    Reads Executions Parses   count total         total
    ------------- -------- --------- -------------------- ------------ ------- -------- ---------------- -------- ---------- ------ ------- ----- -------------
    bsraj0u9r9d3w        1      9368 12-FEB-2016 12:00              14      13      200       14,079,211      780          2      1       1     6             5 --- hard Parse
    bsraj0u9r9d3w        1      9348 11-FEB-2016 16:00             110      91    1,500      104,806,435        0         15      4       1     5             4 --- ??
    bsraj0u9r9d3w        1      9347 11-FEB-2016 15:00              30      29      500       34,922,061        0          5      2       1     5             4 --- ??
    bsraj0u9r9d3w        1      9346 11-FEB-2016 14:00              14      13      200       14,009,248        0          2      1       1     5             4 --- ??
    bsraj0u9r9d3w        1      9341 11-FEB-2016 09:00              14      13      200       14,009,957      651          2      2       1     5             4 --- hard Parse
    bsraj0u9r9d3w        1      9297 09-FEB-2016 13:00              20      20      500       23,380,631        0          5      4       1     4             3 --- ??
    bsraj0u9r9d3w        1      9294 09-FEB-2016 10:00              65      53    1,300       58,569,220        0         13     13       1     3             2 --- ??
    bsraj0u9r9d3w        1      9293 09-FEB-2016 09:00              18      17      300       18,635,057        0          3      2       1     3             2 --- ??
    bsraj0u9r9d3w        1      9292 09-FEB-2016 08:00              70      67    1,700       77,145,560      787         17     17       1     3             2 --- hard Parse
    bsraj0u9r9d3w        1      9272 08-FEB-2016 12:00              18      18      400       22,164,178        0          4      4       1     2             1 --- ??
    bsraj0u9r9d3w        1      9270 08-FEB-2016 10:00             106     101    2,500      123,154,635        0         26     24       1     2             1 --- ??
    bsraj0u9r9d3w        1      9269 08-FEB-2016 09:00              11      10      300       11,401,899      657          3      3       1     2             1 --- hard Parse
    bsraj0u9r9d3w        1      9253 07-FEB-2016 17:00             104      98    2,300      115,320,927      788         23     23       1     1             0 --- hard Parse
    

    Thanks in advance

    Reads disk do not mean that the query will invalidation thus analyze hard. Reading disc mean simply that the IO that happens from disk and it is perhaps due to the result not being not not available in memory.

    I'm not sure why you use this type of analysis to check if requests are going for hard analysis or not? Why not pick up a particular query run and use TKPROF(better SQLTXPLAN) or AWR based SQRPT.sql to check the same? What is the exact issuethat, you're trying to solve?

    Aman...

  • Why do I get a SQL syntax; consult the manual for your version of the MySQL server for the proper syntax

    I have a purchase order where my buyers can add to my form. I use a loop that adds an extra line when they add a new product. I'm storing the information in two tables different mySQL. The first is alll of my personal, the second is the elements. My personal records correctly. However, I get the following error when you save the items:

    You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near 1, 'wer 2345', 1, 1)' on line 9

    The error occurred in E:\webs\clarkwebhosting.com\SSL\esrc\order_add.cfm on line 74

    ++ After storage of the personal information, I take the command ID to populate the table of Articles

    < cflock timeout = "5" >

    < name cfquery = "qGetorderID" datasource = "#application.dsn #" >

    Select max (orderID) as oid of orders

    < / cfquery >

    < / cflock >

    < cfoutput > < cfset getoid = #qGetorderID.oid # > < / cfoutput >

    ++ Is the loop that I use to fill the table items ++

    < cfloop to = "#form.numba # '1' = ' index 'idx' = >"

    < cfset getqty = evaluate ("form.qty" & idx) >

    < cfset getitem = evaluate ("form.item" & idx) >

    < cfset getunit = evaluate ("form.unit" & idx) >

    < cfset gettotal = evaluate ("form.total" & idx) >

    < name cfquery = "insertItems" datasource = "#application.dsn #" >

    INSERT in Articles

    (orderID,

    quantity,

    agenda,

    Unit,

    total

    )

    VALUES)

    < cfqueryparam value = "" #getoid # "CFSQLType ="CF_SQL_INTEGER">"

    < cfqueryparam value = "" #getqty # "CFSQLType ="CF_SQL_INTEGER">,"

    < cfqueryparam value = "" #getitem # "CFSQLType ="CF_SQL_VARCHAR">,"

    < cfqueryparam value = "" #getunit # "CFSQLType ="CF_SQL_INTEGER">,"

    < cfqueryparam value = "" #gettotal # "CFSQLType ="CF_SQL_INTEGER">"

    )

    < / cfquery >

    < / cfloop >

    This line: 1, 'wer' 2345, 1, 1 is the first element of the command line. Any ideas as to why it doesn't work? I use 5.5.9 - log CF9 and mySQL

    My apologies... that should have been (note the quotes)...

    In addition, it would be...

    On another note... You should probably avoid using cfinput and simply use the standard form tags.

  • Create a simple query (SQL)

    Hi experts,

    I have a table with data as follows:

    Database version: 10.2.0.4
    Table name: TRANSACTION_HIST_TAB
    TRANS_ID      LOT_NO    PART_NO    QTY    TRANSACTION         LOCATION_NO    ROWVERSION
    ---------     -------   --------   ----   -----------------   ------------   ----------------------
    T00000X1      L001     ABC         10     CHANGE LOCATION     WRH_1          01/01/13 08:00:00 AM
    T00000X2      L001     ABC        10     CHANGE LOCATION     WRH_2          01/02/13 10:00:00 AM
    T00000X3      L002     XYZ        20     CHANGE LOCATION     WRH_3          01/03/13 11:00:00 AM
    and I want to create a single query (SQL) which can get data grouped by LOT_NO and only the first transaction by LOT_NO

    Expected results:
    TRANS_ID      LOT_NO    PART_NO    QTY    TRANSACTION         LOCATION_NO    ROWVERSION
    ---------     -------   --------   ----   -----------------   ------------   ----------------------
    T00000X1      L001     ABC         10     CHANGE LOCATION     WRH_1          01/01/13 08:00:00 AM
    T00000X3      L002     XYZ        20     CHANGE LOCATION     WRH_3          01/03/13 11:00:00 AM
    Someone has an idea?

    Kind regards

    Rob

    Hi, Rob.

    Here's one way:

    WITH     got_r_num     AS
    (
         SELECT     t.*     -- or list columns you want
         ,     ROW_NUMBER () OVER ( PARTITION BY  lot_no
                                   ORDER BY          rowversion
                           )  AS r_num
         FROM    transaction_hist_tab  t
    )
    SELECT       *     -- or list all columns except r_num
    FROM       got_r_num
    WHERE       r_num     = 1
    ;
    

    Depending on your data and your needs, match Sub like Manik suggested, might work. I think that you want to GROUP BY lot_no only, no transid.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • query sql delicate... date of the created object.

    friends...
    I am trying to solve this query sql delicate for some time, but unable to progress when it comes to this day...

    Q.
    Query dba_objects and list all tables created yesterday ' sysdate - 1' and in another column of the list all the tables created ' sysdate - 7'.

    -query below gives me to yesterday, but don't know how to have 'Last_week' column filled... maybe I join?
    select owner, object_name, to_char(created, 'MM-DD-YYYY HH24:MI:SS') "Yesterday", to_char(created, 'MM-DD-YYYY HH24:MI:SS') "Last_Week"
    from dba_objects
    where object_type = 'TABLE'
    and created >=trunc(sysdate - 1)
    and created < trunc(sysdate)
    appreciate your time and effort in looking at this...

    Thank you

    Published by: khallas301 on March 19, 2013 09:27
    typo edited... Thanks to frank

    khallas301 wrote:
    Query dba_objects and list all tables created yesterday ' sysdate - 1' and in another column of the list all the tables created ' sysdate - 7'.

    Well, sysdate - 7 ways months ago, not last week. If this is what you want, then:

    select  owner,
            object_name,
            case
              when trunc(created) = trunc(sysdate - 1) then to_char(created,'MM-DD-YYYY HH24:MI:SS')
            end "Yesterday",
            case
              when trunc(created) = trunc(sysdate - 7) then to_char(created, 'MM-DD-YYYY HH24:MI:SS')
            end "Week Ago"
      from  dba_objects
      where object_type = 'TABLE'
        and (
                trunc(created) = trunc(sysdate - 1)
             or
                trunc(created) = trunc(sysdate - 7)
            )
    /
    

    SY.

Maybe you are looking for