Rownum with order of Dates of

It's raw data;
SQL SELECT 
  2  DT             ,
  3  CODE       ,
  4  NO         
  5  FROM TB
  6  WHERE DT BETWEEN TO_DATE('01/01/2000','DD/MM/YYYY') AND TO_DATE('31/12/2009','DD/MM/YYYY')
  7  AND BCODE BETWEEN 'B01' AND 'B01'
  8  AND SCODE BETWEEN 'S07' AND 'S07';

DT        CODE              NO
--------- ------ -------------
21-JAN-08 BUY           11.000
06-JAN-08 BUY           12.000
14-JUL-08 SEL            4.000
15-SEP-08 SEL            5.000
13-JAN-09 SEL            6.000
I want the result to give me rownum and trient wise dt
I put this request, but saw only the ranking No. 2 of COL ROWNUM, coming first with dt sorted wise line.
SQL; SELECT rownum,
  2  DT             ,
  3  CODE       ,
  4  NO         
  5  FROM TB
  6  WHERE DT BETWEEN TO_DATE('01/01/2000','DD/MM/YYYY') AND TO_DATE('31/12/2009','DD/MM/YYYY')
  7  AND   BCODE BETWEEN 'B01' AND 'B01'
  8  AND   SCODE BETWEEN 'S07' AND 'S07'
  9  order by invxh_DATE;

       ROWNUM DT        CODE              NO
------------- --------- ------ -------------
        2.000 06-JAN-08 BUY           12.000
        1.000 21-JAN-08 BUY           11.000
        3.000 14-JUL-08 SEL            4.000
        4.000 15-SEP-08 SEL            5.000
        5.000 13-JAN-09 SEL            6.000
I want to be generetd wise dt, rownum, something like;
       ROWNUM DT        CODE              NO
------------- --------- ------ -------------
        1.000 06-JAN-08 BUY           12.000
        2.000 21-JAN-08 BUY           11.000
        3.000 14-JUL-08 SEL            4.000
        4.000 15-SEP-08 SEL            5.000
        5.000 13-JAN-09 SEL            6.000

There is a built-in feature to this:

SELECT ROW_NUMBER () OVER (ORDER BY dt) rownmbr, dt, code, no
  FROM tb
 WHERE dt BETWEEN TO_DATE ('01/01/2000', 'DD/MM/YYYY')
              AND TO_DATE ('31/12/2009', 'DD/MM/YYYY')
   AND bcode BETWEEN 'B01' AND 'B01'
   AND scode BETWEEN 'S07' AND 'S07';

Published by: Slow_moe on January 18, 2009 04:19

Sorry! Of course, it must be a DATE data type...

Tags: Database

Similar Questions

  • using rownum with order by

    Hi all

    I want to use rownum with order of clause-

    When I use an order clause in the select query, I get so many lines that I don't want.
    I have average-i want only two first rows according to the order of.

    EG. - Select employee_id, salary of the order of salary employees;
    EMPLOYEE_ID, FIRST_NAME SALARY
    ----------- -------------------- --------
    132 2100 TJ
    Steven 128 2200
    2200 hazelnut 136
    James 127 2400
    135 Ki 2400

    now, I just want to see the first two lines of the output above.
    any oneone please help does
    SQL> SELECT *
    FROM   (SELECT employee_id,
                   first_name,
                   salary
            FROM   employees
            ORDER  BY salary)
    WHERE  ROWNUM < 3;   2    3    4    5    6    7  
    
    EMPLOYEE_ID FIRST_NAME               SALARY
    ----------- -------------------- ----------
            132 TJ                         2100
            128 Steven                     2200
    
  • Problem with order submit data record for Reporting ATG

    Hi, r. j. Nunes

    I am facing problems with the connection to present newspapers for ATG of the report. The logs for RegistrationFileLogger, SiteVisitFileLogger, UserFileLogger, SegmentFileLogger were successfully getting generated but unable to see the logs for OrderFileLogger during shipment of the order.

    I understand that the/atg/reporting/datacollection/trade/SubmitOrderEventListener of the listener must be notified so that the listeners of corresponding data is called in the order:

    SubmitOrderEventListener-> OrderLogEntryQueueSink-> OrderLogEntryGenerator-> OrderFileLogger

    and newspapers would be written.

    But I'm not able to determine which component notifies the SubmitOrderEventListener by submitting an order.


    Is - this SendFulfillmentMessage component? But SendFulfillmentMessage sends the message to the localdms topic: / local/realization/LocalSubmitOrder on the port of OrderSubmitPort which as component SubmitOrderEventListener listen the subject localdms: / local/realization/LocalSubmitOrder on the DEFAULT port?


    Could someone please clarify.

    Thank you

    Saud

    Hello

    Pipelinelink = "sendFulfillmentMessage" name has been commented to our commercepipeline.xml that we did not use OOTB Presse. Once I removed the comment, sent messages and newspapers to submit order got generated.

    Thank you

    Saud

  • Problem with order by Date

    Apex 3.2

    I have a report based on a collection, but the ranking of start_date and end_date does not work.

    Select

    C002 start_date,

    C003 end_date,

    -start_date to_char (to_date (c002, 'dd.mm.yyyy'), 'dd.mm.yyyy'),

    -End_date to_char (to_date (c003, 'dd.mm.yyyy'), 'dd.mm.yyyy'),

    C004 conversion_factor,

    SI.apskey SMI,

    SI.longdescr Description

    to apex_collections, if udm_si

    where si.siid = c001

    and collection_name = "SMI_INSERT_COL."

    I tried

    C002 start_date,

    C003 end_date

    and put exact in the formatting of column

    I tried

    start_date to_char (to_date (c002, 'dd.mm.yyyy'), 'dd.mm.yyyy'),

    -End_date to_char (to_date (c003, 'dd.mm.yyyy'), 'dd.mm.yyyy'),

    with no formatting of column

    I also tried

    start_date to_char ("c002, ' dd.mm.yyyy")

    but I get an error

    error report:

    ORA-01722: invalid number

    Gus

    Some previous threads please refer to "-" the origin of this. Try to split the "-"s: ".

    ' ': apex_item.display_and_save (2, c002)

  • Order by date with a format mask column

    10g - 10.2.0

    Hello

    This is my request
    select to_char(exp_Date,'Mon-YYYY') dt, count(*) from exp_main
    where exp_type like 'Income%Photo%'
    group by to_char(exp_Date,'Mon-YYYY')
    order by exp_date
    
     
    When I run this I get: not a GROUP BY expression

    If I remove the order by, it works fine.

    Is it possible to order by since the output of the query is sorted character.

    I search online most suggested to use the order of column_name. But does not work for me.

    Thank you!
    Ryan

    Hello

    Keep the date information as a DATE, with the exception (if required) for display. That means that GROUP BY and ORDER BY DATE, not a string:

    SELECT    TO_CHAR ( TRUNC (exp_Date, 'MONTH')
                  , 'Mon-YYYY'
                )          AS dt
    ,       COUNT (*)           AS cnt
    FROM        exp_main
    WHERE        exp_type     LIKE 'Income%Photo%'
    GROUP BY  TRUNC (exp_Date, 'MONTH')
    ORDER BY  TRUNC (exp_date, 'MONTH')
    ;
    
  • Seen the clause and order by date

    Hello
    I have a query in which I use the having clause (have rownum between 1 and 10) and you want to order by date, but the result sorts data correctly. The result is not sorted by date.
    The query looks like this

    Select rownum, MTT_HANDHELD_TRANS.hh_RECEIPT, MTT_HANDHELD_TRANS.hh_lic_number and MTT_TOLL_PLAZAS. Acronym of TP_ABBREVIATION AS,
    MTT_HANDHELD_TRANS. HH_PLAZA AS, MTT_HANDHELD_TRANS PLAZA. AS Lane, MTT_HANDHELD_TRANS HH_LANE. HH_TRX_DATE as TrxDate,
    TO_CHAR (MTT_HANDHELD_TRANS. HH_TRX_DATE, 'hh24:mi:ss') AS TrxTime, MTT_HANDHELD_TRANS. HH_VEHICLE_TYPE, MTT_HANDHELD_TRANS. HH_AXLES,
    get_tolltobecollected (hh_plaza, hh_vehicle_type, hh_axles, hh_trx_date, hh_tow_vehicle_type, hh_tow_axles) as TollCollect,
    Decode (NVL(hh_serfee_waived,0), 0, 'No', 'Yes') as the exclusions, hh_waiver_comments, hh_lic_state, hh_monitor, hh_defcashkeyno,.
    As paid NVL(hh_paid,0) FROM MTT_HANDHELD_TRANS, MTT_TOLL_PLAZAS WHERE HH_PLAZA is MTT_TOLL_PLAZAS. TP_PLAZA and hh_remark = 1
    and (trunc (hh_trx_date) between to_date (' 05/01/2010 ',' mm/dd/yyyy') and to_date (' 05/03/2010 ',' mm/dd/yyyy'))
    Group of rownum, hh_receipt, hh_lic_number, tp_abbreviation, hh_plaza, hh_lane, hh_trx_date, hh_vehicle_type,
    hh_axles, hh_serfee_waived, hh_waiver_comments, hh_lic_state, hh_monitor, hh_tow_vehicle_type, hh_tow_axles,
    hh_defcashkeyno, hh_paid have rownum between 1 and 10
    order of hh_trx_date

    Rather than display the data with the date 01/05/2010 first of all, it shows 2010-05-02 and data with 01/05/2010 comes from somewhere between the other dates, I think that is data are themselves mixed up. Is there a way can I fix?

    Thank you.
  • help with LAG () AND dates

    I have at this moment the following query
      SELECT "DATE",
              "CELL_SITE",
              "LASTV_ATTCNT",
              "LASTV_ATTCNT2",
              "LASTV_BLKCNT",
              "LASTV_DRPCNT",
              "V_ATT_CNT",
              "V_CUST_BLK_CNT",
              "V_DRP_CALL_CNT",
              "LASTD_ATTCNT",
              "LASTD_BLKCNT",
              "LASTD_DRPCNT",
              "D_ATT_CNT",
              "D_CUST_BLK_CNT",
              "D_DRP_CALL_CNT"          
         FROM (  SELECT DATE,
                       CELL_SITE,
                        LAG (SUM (V_ATT_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTV_ATTCNT",
                        LAG (SUM (V_CUST_BLK_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTV_BLKCNT",
                        LAG (SUM (V_DRP_CALL_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTV_DRPCNT",
                        LAG (SUM (D_ATT_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTD_ATTCNT",
                        LAG (SUM (D_CUST_BLK_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTD_BLKCNT",
                        LAG (SUM (D_DRP_CALL_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTD_DRPCNT",
                        SUM (V_ATT_CNT) AS "V_ATT_CNT",
                        SUM (V_CUST_BLK_CNT) AS "V_CUST_BLK_CNT",
                        SUM (V_DRP_CALL_CNT) AS "V_DRP_CALL_CNT",
                        SUM (D_ATT_CNT) AS "D_ATT_CNT",
                        SUM (D_CUST_BLK_CNT) AS "D_CUST_BLK_CNT",
                        SUM (D_DRP_CALL_CNT) AS "D_DRP_CALL_CNT"
                   FROM DMSN.DS3R_FH_1XRTT_FA_LVL_KPI
                  WHERE DATE >
                             (SELECT MAX (DATE) FROM DMSN.DS3R_FH_1XRTT_FA_LVL_KPI)
                           - 2
               GROUP BY DATE, CELL_SITE)
        WHERE DATE >=
                 (SELECT MAX (DATE) - NUMTODSINTERVAL (12, 'HOUR')
                    FROM DMSN.DS3R_FH_1XRTT_FA_LVL_KPI)
    What I've noticed, is that the LAG function is kind of what I want but not exactly. Let's say that I have given for the hours of 12: 00, 01:00, 02:00, 03:00 04:00, 05:00, 06:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00 and the time is 12:00, the LAG function goes back to 12 h, which is what he should do.

    but lets say that I have given for 12 h, 01:00, 02:00, 03:00 04:00, 05:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00, but it me MISSING at 06:00 (no data from 06:00). The lag function now back at 23:00 instead of 12 AM because the time 06:00 is missing.

    If I have data for 12: 00 01:00, 02:00, 03:00 04:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00 and am MISSING 05:00 and 06:00, the data will return to 22:00 then and not only from 12: 00.

    Can I prevent this and always just come back in 12 hours?

    Published by: k1ng87 on April 25, 2013 13:27

    Hello

    k1ng87 wrote:

    ...
    LAG (SUM (V_ATT_CNT), 24)
    OVER (PARTITION BY BSM_NM ORDER BY DATE)
    AS "LASTV_ATTCNT",
    LAG (SUM (V_CUST_BLK_CNT), 24)
    OVER (PARTITION BY BSM_NM ORDER BY DATE)
    AS "LASTV_BLKCNT",
    LAG (SUM (V_DRP_CALL_CNT), 24)
    OVER (PARTITION BY BSM_NM ORDER BY DATE)
    AS "LASTV_DRPCNT",
    ...
    

    Since you want to so many columns of the same previous row, it would be probably easier and more effective to make a self-join, rather than so many functions of SHIFT.

    What I've noticed, is that the LAG function is kind of what I want but not exactly. Let's say that I have given for the hours of 12: 00, 01:00, 02:00, 03:00 04:00, 05:00, 06:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00 and the time is 12:00, the LAG function goes back to 12 h, which is what he should do.

    You always pass 24 as 2nd argument offset; What does "Return the value of the line 24 of the precding." If there is a line for each hour, the current line is from 12:00, then wouldn't 24 ranks back would be from 12:00 yesterday, not 12 AM? Maybe you wanted to spend 12, not 24, as the second argument of LAG. I'll assume you really want the 24 line rom now on, but the technique is the same that that number either 24 or 12.

    but lets say that I have given for 12 h, 01:00, 02:00, 03:00 04:00, 05:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00, but it me MISSING at 06:00 (no data from 06:00). The lag function now back at 23:00 instead of 12 AM because the time 06:00 is missing.

    If I have data for 12: 00 01:00, 02:00, 03:00 04:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00 and am MISSING 05:00 and 06:00, the data will return to 22:00 then and not only from 12: 00.

    Can I prevent this and always just come back in 12 hours?

    A self-join would handle this automatically: it will look for the corresponding line, without regard for other lines may be present or absent.

    If you really had to do with the analytical functions, you can use MIN or FIRST_VALUE with a window of the range:

    RANGE BETWEEN  1 + (.5 / 24)  PRECEDING
          AND      1 - (.5 / 24)  PRECEDING
    

    DATE when you ORDER BY a column (do not call ' DATE'), the units are 1 day, so 1 + (.5/24) days ago is 24.5 hours; in other words, the window includes only DATES between 24.5 and 23.5 hours.

    If, for some reason, you really want to call LAG, so you could do an outer join to ensure that a row had been present for each of the previous 24 hours.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these 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}

  • Problem with order by clause

    Hai all,

    I have problem with order by clause,

    My query is

    "Select number from table1 order number CSA.

    and the output as

    1
    10
    12
    13
    15
    17
    19
    2
    20
    21
    22
    .
    ........

    But if we give the order that it should display below the only good?

    1
    2
    10
    12
    13
    15
    17
    19
    20
    21
    22 ........

    Help me please why it is not displayed as she. and how to make the statement to display as in the second case. Thanks in advance.

    Kind regards
    Uraja

    In your table, the column is VARCHAR2 data type.

    It is a string, even if it is to store numeric values, it will get condemn as strings

    Try the below

    select your_column from table1 order by to_number(your_column) asc 
    

    Published by: JAC on November 19, 2012 16:35

  • Separate option is not allowed with Order By.

    Hi all
    I use a parameter in a query for a report like this:

    Select Name, Id
    of employees, emp_orders
    where employees.id = emp_orders.id - table employees is the master
    and (: order_type_id is null or)
    ((: order_type_id = emp_orders.order_type_id)) -: order_type_id is the user setting
    order of employees.seq_no

    the above query runs successfully but it doubles the data for employees with more than one order, if it has two orders, as it returns records for same twice and if it is of three that it returns the same records for three times!
    I tried to fix it by putting the Distinct after select Word option, but in this case, it gives me this error:
    ORA-01791: not a SELECTed expression

    and when I remove the order by expression data duplication is gone like wanted!

    How to solve the problem please? Thank you
    Note: I use Oracle reports 6i

    http://ORA-01791.ora-code.com/

    Separate option is not allowed with Order By.

    Why

    SQL> with t as
      2  (
      3    select 1 id, 'str' str from dual union all
      4    select 2 id, 'str' str from dual union all
      5    select 1 id, 'str' str from dual
      6  )
      7  select id, str from t
      8  order by id, str
      9  /
    
            ID STR
    ---------- ---
             1 str
             1 str
             2 str
    
    SQL>
    SQL> with t as
      2  (
      3    select 1 id, 'str' str from dual union all
      4    select 2 id, 'str' str from dual union all
      5    select 1 id, 'str' str from dual
      6  )
      7  select distinct id, str from t
      8  order by id, str
      9  /
    
            ID STR
    ---------- ---
             1 str
             2 str
    
    SQL> 
    

    You can try to group by

    SQL> with t as
      2  (
      3    select 1 id, 'str' str from dual union all
      4    select 2 id, 'str' str from dual union all
      5    select 1 id, 'str' str from dual
      6  )
      7  select id, str from t
      8  group by id, str
      9  order by id, str
     10  /
    
            ID STR
    ---------- ---
             1 str
             2 str
    
    SQL> 
    
  • How do I get the data in order by date

    Hello

    I get the data as below, I need the data with null values

    Date col1 col2 col3 col4
    16 November 11 23
    November 17 11 12
    18 November 11 321
    19 November 11 23
    20 November 11 132
    2321 16 November 11
    17 November 11 112
    18 November 11 211
    19 November 11 132
    November 20, 11 12
    16 November 11 45
    17 November 11 465
    2123 18 November 11
    19 November 11 132
    20 November 11 65
    16 November 11 456
    17 November 11 546
    4656 November 18, 11
    19 November 11 566
    20 November 11 564

    need output like below

    Date col1 col2 col3 col4
    16 November 11 23 2321 45 456
    November 17 11 12 112 465 546
    18 November 11 321 211 2123 4656
    19 November 11 23 132 132 566
    20 November 11 132 12 65 564

    Thanks in advance,
    Vincent.

    Delighted ADIK wrote:
    Please post requests INSERT such as requested by another user of the forum. Also mention the version of Oracle.

    Please search for WM_CONCAT.

    http://www.Oracle-base.com/articles/Misc/StringAggregationTechniques.php

    Yes, search for WM_CONCAT, and then COMPLETELY IGNORE IT because it is not the right way to do things. It is undocumented and should not be used similarly recommended.

    Even Tom Kyte says that you should not use it...

    Re: SEPARATE does not not with wmsys.wm_concat

    WM_CONCAT is also an aggregation of chain function, and is not what the OP's request.

    Frank gave the good solution, as evidenced by...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select to_date('16-Nov-11','DD-Mon-RR') as dt, 23 as col1, null as col2, null as col3, null as col4 from dual union
      2             select to_date('17-Nov-11','DD-Mon-RR'), 12, null, null, null from dual union all
      3             select to_date('18-Nov-11','DD-Mon-RR'), 321, null, null, null from dual union all
      4             select to_date('19-Nov-11','DD-Mon-RR'), 23, null, null, null from dual union all
      5             select to_date('20-Nov-11','DD-Mon-RR'), 132, null, null, null from dual union all
      6             select to_date('16-Nov-11','DD-Mon-RR'), null, 2321, null, null from dual union all
      7             select to_date('17-Nov-11','DD-Mon-RR'), null, 112, null, null from dual union all
      8             select to_date('18-Nov-11','DD-Mon-RR'), null, 211, null, null from dual union all
      9             select to_date('19-Nov-11','DD-Mon-RR'), null, 132, null, null from dual union all
     10             select to_date('20-Nov-11','DD-Mon-RR'), null, 12, null, null from dual union all
     11             select to_date('16-Nov-11','DD-Mon-RR'), null, null, 45, null from dual union all
     12             select to_date('17-Nov-11','DD-Mon-RR'), null, null, 465, null from dual union all
     13             select to_date('18-Nov-11','DD-Mon-RR'), null, null, 2123, null from dual union all
     14             select to_date('19-Nov-11','DD-Mon-RR'), null, null, 132, null from dual union all
     15             select to_date('20-Nov-11','DD-Mon-RR'), null, null, 65, null from dual union all
     16             select to_date('16-Nov-11','DD-Mon-RR'), null, null, null, 456 from dual union all
     17             select to_date('17-Nov-11','DD-Mon-RR'), null, null, null, 546 from dual union all
     18             select to_date('18-Nov-11','DD-Mon-RR'), null, null, null, 4656 from dual union all
     19             select to_date('19-Nov-11','DD-Mon-RR'), null, null, null, 566 from dual union all
     20             select to_date('20-Nov-11','DD-Mon-RR'), null, null, null, 564 from dual)
     21  --
     22  -- end of test data
     23  --
     24  select dt
     25        ,max(col1) as col1
     26        ,max(col2) as col2
     27        ,max(col3) as col3
     28        ,max(col4) as col4
     29  from t
     30  group by dt
     31* order by dt
    SQL> /
    
    DT                COL1       COL2       COL3       COL4
    ----------- ---------- ---------- ---------- ----------
    16-Nov-2011         23       2321         45        456
    17-Nov-2011         12        112        465        546
    18-Nov-2011        321        211       2123       4656
    19-Nov-2011         23        132        132        566
    20-Nov-2011        132         12         65        564
    
    SQL>
    
  • Problem with order of clip

    This is a question and request for suggestions.
    I'm very new to using first Pro CS4 using VideoStudio for a long time. But due to a mutitude of bug and constant crashes, I just let fall on her and made the transition to the first.

    I begin to develop projects of AVCHD clips. My camera creates each scene as a file. With VideoStudio I had to use TSmuxeR to merge them into a single clip, otherwise it would just fall more take hours (literally) to start because she wanted to check each hook. When you have hunderds in a project it is a problem.

    Prime Minister handles this much better doing things in the background, but I had some problems with clips are reordered. Maybe my approach is all wrong and I'm open to suggestions.

    For example, I break the clips in segments that relate to a topic and put in a bin. So, in a project, I would have 700 clips into 10 bins with 50 to 100 clips in each location. And I might have a dozen projects which constitute a 'production '. But when I import clips (IE windows) the last clip always happens to be the first imported. It is a common windows problem which I do not know how to move. In any case, when it gets imported I then rearrange clips. Clips from your device name is a time code date as 20100514082312.mts which is unique and you can order by date very easily, but it is really hard to read.

    The problem that I seem to have if I take a bin (that' it'sbeen sort) and drag it to the timeline, the last clip gets always inserted first. I guess that the Prime Minister is to remember the order that the clips had import and not how I trie in the bins.

    Because I tend to move things around a lot, it is a concern to keep deting first clips and then put on the end of the sequence, etc..

    Is there a way to get around this? As do enforcement in the stick of bins, or order the clips by name in the time line or maybe bring imported in the correct order in the first place?

    Or is the way I'm doing this all wrong. I admit it's hard to give up the way I did things in VideoStudio which could impose some bad habits.

    There is something else you can try - select the media and to automate for the timeline. You can tell it to not add transitions and do not overlap, and there are options to overlay the clips in the order of sorting or the order of selection. Try to select clips in the order of your choice.

    If there is something else in the trash you want, like a sequence, you may need to select all, uncheck what you want and then automate.

  • Problem with "Query" parameter data pump

    Hello guys,.

    My information in the table are less than
    Name of the schema: CT_COM
    Table name: order_session
    The current size of the table = ~ 75
    Total number of rows in the table: 3847904-> select count (*) from CT_COM.order_session;
    Total number of lines with condition: 734042 (orders over 1 January 08)-> select count (*) from CT_COM.order_session where updated_date < = 31 December 07 ';


    Now, I'm taking an export in which I want to capture all the orders that are placed before 1 January 08. Here's the query I use on a DB of RHEL server. I 10.2.0.3 db on this server.

    expdp "" / as sysdba "" logfile = FULL_TABLE:order_session_upto_dec_31_07.log query = CT_COM.order_session dumpfile=FULL_TABLE:order_session_upto_dec_31_07_%U.dmp:------"" where updated_date------<------= \'31-DEC-07\'\ ' filesize = 2 G job_name = order_session_upto_dec_31_07 "

    Export: Release 10.2.0.3.0 - Production on Wednesday, August 4, 2010 16:11

    Copyright (c) 2003, 2005, Oracle. All rights reserved.

    Connected to: Oracle Database 10g Release 10.2.0.3.0 - Production
    Departure 'SYS '. "' ORDER_SESSION_UPTO_DEC_31_07 ': ' / * AS SYSDBA' dumpfile=FULL_TABLE:order_session_upto_dec_31_07_%U.dmp logfile = FULL_TABLE:order_session_upto_dec_31_07.log query = CT_COM.order_session:" "where updated_date < = 31 December 07 ' ' filesize = 2 G job_name = order_session_upto_dec_31_07"
    Current estimation using BLOCKS method...
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 0 KB
    Processing object type SCHEMA_EXPORT/ROLE_GRANT
    Table main 'SYS '. "' ORDER_SESSION_UPTO_DEC_31_07 ' properly load/unloaded
    ******************************************************************************
    Empty the files together for SYS. ORDER_SESSION_UPTO_DEC_31_07 is:
    /Backup/export/tables/order_session_upto_dec_31_07_01.dmp
    Job 'SYS '. "" ORDER_SESSION_UPTO_DEC_31_07 "carried out at 16:11:31

    Query runs fine without error. However if you look at the output above it exports all lines. I keep seeing Total estimation using BLOCKS method: 0 KB. -What did I do wrong?

    I even tried the same scenerio with table scott.emp and I see the same behavior. Did I miss something in my where clause or is this a bug?

    Expdp $ Linux-223: (bonus) "" / as sysdba "" dumpfile=full_table:a%U.dmp logfile = FULL_TABLE:a.log query = scott.emp:------"' where sal------> 2000------' filesize = 2 G job_name = b.job"

    Export: Release 10.2.0.4.0 - Production on Wednesday, August 4, 2010 15:11:31

    Copyright (c) 2003, 2007, Oracle. All rights reserved.

    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With partitioning, OLAP, Data Mining and Real Application Testing options
    Departure 'SYS '. "' B ': ' / * AS SYSDBA' dumpfile=full_table:a%U.dmp logfile = FULL_TABLE:a.log query = scott.emp:" where sal > 2000 "filesize = 2 G job_name = b.job
    Current estimation using BLOCKS method...
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 0 KB
    Processing object type SCHEMA_EXPORT/ROLE_GRANT
    Table main 'SYS '. "' B ' properly load/unloaded
    ******************************************************************************
    Empty the files together for SYS. B is:
    /tmp/A01.dmp
    Job 'SYS '. "' B ' managed to 15:12:46


    Any help will be appreciated.


    -MM

    Published by: UserMM on August 4, 2010 14:48

    It has nothing to do with your request, it has to do with the rest of your order expdp. You specify a schema on the table, or you specified an export scheme so default datapump is the schema to run the task. As you export the work as "sys" it will only export objects belonged to sys. Since datapump does not export the sys objects, nothing get exported. You want to add

    schemas = CT_COM

    or

    tables = CT_COM.order_session

    Thank you

    Dean

  • Need help with RANK() on data ZERO

    Hi all

    I am using Oracle 10 g and running a query with RANK(), but it is not a desired output. Pleas HELP!

    I have a STATUS table, which shows the history of the State of the command... I have a requirement to indicate the order and the last date of State (max). If there is no date NULL for a command can show NULL.

    STATUS
    ------------
    ORD_NO | STAT | DT
    ---------------------------------------------
    1. Open |
    1. Pending |
    2. Open |
    2. Pending |
    3. Open | 01/01/2009
    3. Pending | 06/01/2009
    3. Close |
    4. Open | 02/03/2009
    4. Close | 04/03/2009
    Result should be (max date for each ORD_NO NULL otherwise):
    ORD_NO | DT
    ---------------------------------------------
    1.
    2.
    3.
    4. 04/03/2009
    ----------------------------------------------
    CREATE THE TABLE Status (NUMBER of ORD_NO, STAT VARCHAR2 (10), DT DATE);
    INSERT INTO the status of the VALUES (1, 'Open', NULL);
    INSERT INTO the status of VALUES (1, 'Waiting', NULL);
    INSERT INTO the status of VALUES (2, 'Open', NULL);
    INSERT INTO the status of VALUES (2, 'Waiting', NULL);
    INSERT INTO the status of VALUES (3, 'open', 1 JAN 2009');
    INSERT INTO the status of VALUES (3, 'pending', 6 JAN 2009');
    INSERT INTO status VALUES (3, 'Close', NULL);
    INSERT INTO the status of VALUES (4, 'open', 2 MAR 2009');
    INSERT INTO status VALUES (4, 'Close', 4 MAR 2009');
    COMMIT;

    I tried using the RANK function to rank all orders by date. So accustomed ORDER BY cluse to date down the order dates thinking null would be on top and is grouped by each ORD_NO.

    SELECT ORD_NO, DT, RANK() OVER (ORDER BY DT DESC ORD_NO PARTITION)
    STATUS;

    .. but the result was something...
    ORD_NO | DT | RANKING
    ---------------------------------------------
    *1 | | 1 *.
    *1 | | 1 *.
    *2 | | 1 *.
    *2 | | 1 3 | 1
    3. 06/01/2009 | 2
    3. 01/01/2009 | 3
    4. 2009-03-04 | 1
    4. 02/03/2009 | 2
    ----------------------------------------------

    I don't know why, is not the first two ORD_NOs has no group and why the ranking of 1 assigned to them. I'm assuming something like:
    ORD_NO | DT | RANKING
    ---------------------------------------------
    *1 | | 1 *.
    *1 | | 0 h
    *2 | | 1 *.
    *2 | | 1 *.
    3 | | 1
    3. 06/01/2009 | 2
    3. 01/01/2009 | 3
    4. 2009-03-04 | 1
    4. 02/03/2009 | 2
    ----------------------------------------------

    Please guide me if I am missing something here?

    Concerning
    Sri

    Hello

    I think the last stat for 1 and 2 is ongoing unopened.

    Salim cordially.

    SQL> SELECT   ord_no, MAX (stat)KEEP (DENSE_RANK LAST ORDER BY dt) stat,
      2           MAX (dt)KEEP (DENSE_RANK LAST ORDER BY dt) dt
      3      FROM status
      4  GROUP BY ord_no;
    
        ORD_NO STAT       DT
    ---------- ---------- ----------
             1 Pending
             2 Pending
             3 Close
             4 Close      2009-03-04
    
    SQL> 
    

    Published by: Salim champion 2009-05-05 13:09

  • update with order by

    Hi all

    Does anyone know if "in order to" has the priority on "updates"? In other words, by using the following query. Will be sorted first and then locked resulting lines or they will be locked everything first, and then sorted?

    SELECT / * + cardinality (para. 1) use_nl (al t) * / NULL
    LOOSE COLLECTION l_nullvalue_list
    TABLE (i_list), my_table t Al
    WHERE al.id = t.id
    ORDER BY t.id
    FOR the UPDATE OF t.id;

    Any help is appreciated.

    Kind regards
    WF

    It is the case that I do not speak:

    drop table t cascade constraints purge;
    create table t as select rownum id, cast('x' as char(100)) pad
                        from dual connect by level <= 10000;
    
    drop table t1 cascade constraints purge;
    create table t1(id int);
    
    -- 1st session
    SQL> lock table t1 in exclusive mode;
    
    Table(s) locked
    
    -- 2nd session
    declare
        type t1_type is table of rowid index by binary_integer;
        l_tab t1_type;
    begin
        execute immediate 'lock table t1 in share mode';
        select rowid bulk collect into l_tab
          from t order by dbms_random.value
           for update;
    end;
    /
    
    -- 3rd session
    declare
        type t1_type is table of rowid index by binary_integer;
        l_tab t1_type;
    begin
        execute immediate 'lock table t1 in share mode';
        select rowid bulk collect into l_tab
          from t order by dbms_random.value
           for update;
    end;
    /
    

    Now 2nd & 3rd sessions are blocked by the 1st. We will release the lock:

    -- 1st session
    SQL> commit;
    
    Commit complete
    

    2nd & 3rd sessions try to lock the rows of the table T, and fails one of the sessions with blocking:

    declare
        type t1_type is table of rowid index by binary_integer;
        l_tab t1_type;
    begin
        execute immediate 'lock table t1 in share mode';
        select rowid bulk collect into l_tab
          from t order by dbms_random.value
           for update;
    end;
    
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at line 7
    

    If you repeat the same scenario with ORDER BY id, then a session will wait to enqueue.
    So, it's all on the order in which the row locks are acquired.

  • Help with order by clause

    Hello

    I have a table with the data below, when I run my select with order option gives me
    1 card

    as a first line, but I need it
    12 atm

    as the first line, how this is possible.



    create table test
    (Identification number,
    Val varchar2 (20)
    )


    insert into test values (1, 'Card')
    Insert test values (2, ' map')
    Insert test values (3, ' map')

    Insert test values (4, 'cash')
    Insert test values (5, 'Cash')
    Insert test values (6, 'cash')

    Insert test values (7, "Checque")
    Insert test values (8, "Checque")
    Insert test values (9, "Checque")

    Insert test values (10, 'atm')
    insert into test values (11, 'atm')
    Insert test values (12, 'atm')



    Select * from test
    order by ASC of val

    Or try again with

     select * from test order by upper(val) asc, id desc 
    

Maybe you are looking for

  • Laptop HP 2000: System disabled hp 2000 Code 98717430

    The HP 2000 I don't know that number is98 disabled password systemcan 717430 someone help

  • Extender wireless Xbox with an xbox game?

    I need to extend the range of my wireless controller.  I wonder if I can do this with an Extender for wireless game xbox plugged into the USB port on the xbox 360.   Does anyone know if it would work or if the extension of wireless game works only wi

  • resolution of Blackberry

    I work above jdk 6.0, what lower resolution to consider? I put a statically 48 pic by 48 pixel... I want to know if I need to bother resizing.

  • Number of authorized computers

    I have a teaching CC license. I understand that I am allowed 2 installations of a product.Can I use more than 2 computers for example having animate CC on my laptop and my main desktop iMac computer AND have video / picture on my father more powerful

  • Why do some images disappear in AS3?

    There are 17 symbols has my project. Each symbol contains an image. It's displaying required 9 random images and mix. symbols are named: p1, p2, p3 and so on... The project works properly, but only one or two images disappears from the 9 random image