Avoiding the clues in this query

Hi I have the following query that produces this execution plan.
My question is that, given that the optimizer made a complete analysis of table ((je pense que son dû de se connecter par avant dans la requête,...))
because the full table scan happens why additonally go to the index. avoid access index here how we can save additional time to index will allow you to join.
I can't help but full table scan because using connect by clause.

I want to remove access from the index because the optimizer will still choose a full table scan for table prod_dim to step 3
SELECT  prod_dim_nb, prod_type_nm, prod_fam_cd, prod_cd,
                      prod_shrt_nm, prod_full_nm,
                      LTRIM (SYS_CONNECT_BY_PATH (prod_cd, '/'),
                             '/'
                            ) product_hierarchy
                 FROM prod_dim
                WHERE prod_fam_cd = 'ABC'
           START WITH prod_dim_nb = prnt_prod_dim_nb
           CONNECT BY NOCYCLE prnt_prod_dim_nb = PRIOR prod_dim_nb
           
   
PLAN_TABLE_OUTPUT
 
-----------------------------------------------------------------------------------------------
| Id  | Operation                      | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |              |     3 |   258 |     2   (0)| 00:00:01 |
|*  1 |  FILTER                        |              |       |       |            |          |
|*  2 |   CONNECT BY WITH FILTERING    |              |       |       |            |          |
|*  3 |    TABLE ACCESS FULL           | PROD_DIM     |     1 |    86 |     3   (0)| 00:00:01 |
|   4 |    NESTED LOOPS                |              |       |       |            |          |
|   5 |     CONNECT BY PUMP            |              |       |       |            |          |
|   6 |     TABLE ACCESS BY INDEX ROWID| PROD_DIM     |     3 |   258 |     2   (0)| 00:00:01 |
|*  7 |      INDEX RANGE SCAN          | PROD_DIM_FK2 |     3 |       |     1   (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------


   
is my understanding... do we really need to go to the index when its goes not for full access to the table in step 3 in the plan? How to avoid the 6 and 7?

Published by: raj_fresher on September 3, 2009 15:52

I checked all the columns in the select clause, and they are not null columns

But the optimizer does not know that (unless you have NO constraints of NULL in all your columns).

but he's still going for full table access

This is not surprising. Your table is extremely low (or at least the optimizer thinks that Yes). It's probably going to be faster for analysis complete one or two blocks from the table to use multiple indexes.

Tags: Database

Similar Questions

  • is it far to disable the shortcut ctrl-alt-tab on windows 7 (cycle between windows) to avoid the substitution of this same shortcut (indented) in excel?

    is it far to disable the shortcut ctrl-alt-tab on windows 7 (cycle between windows) to avoid the substitution of this same shortcut (indented) in excel?

    Hello
     
    The feature you're talking about is the default value of design in Windows 7. If you have comments or suggestions, you can post your query to the Windows 7 feedback forum.

     
  • What is the name of this query

    Hi all

    I want to know the name of this query to learn about it, because I don't understand how it works.

    Select the columns tab "(select table columns)" table.

    I saw him, but I don't know how it works.

    Thanks in advance

    It is a scalar subquery expression.

    "An expression of scalar subquery is a subquery that returns exactly one column of a line."

    The value of the scalar subquery expression is the value of the select item from the list of the subquery.

    If the subquery returns 0 rows, then the value of the scalar subquery expression is NULL.

    If the subquery returns more than one line, then Oracle returns an error. »

    See:

    http://docs.Oracle.com/CD/E16655_01/server.121/e17209/expressions013.htm#SQLRF52093

    For example, we can write

    Select empno,

    Ename,

    DEPTNO,

    (select dname dept where deptno = emp.deptno) dname

    WCP

    order by empno

    /

    Instead of

    Select e.empno,

    e.Ename,

    e.DEPTNO,

    d.DNAME

    from emp e,.

    d Dep.

    where e.deptno = d.deptno

    order by empno

    /

  • What can I do to prevent the failure of this query

    Someone used our search engine to submit the search term "NT the Australia".

    With the help of Barbara in several positions before this one, we have a thesaurus that transforms "NT" in "Northern Territory".

    If the "analysis function" I wrote eventually transform the search of this query string:
    select * from search_table where contains(keyfield,'(nt|northern territory) and (australia)')>0
    But which causes this error:

    -20000:ORA - 20000: Oracle Text error: DRG-10800: failed to query:

    I assume that the problem is "NT", which is taken to mean 'short term', rather than the State abbreviation. The same type of problem that can occur when someone searches for BT, which means 'British Telecom', but I imagine that this will be interpreted to mean "generic term".

    What is the usual way to stop these kinds of questions? I can write the code that replaces "NT" by "northern territory" before I even touched my dictionary of synonyms... but if I'm going to hardcode things like that, what else I'd be worried? And although I could replace 'BT' by 'british telecom', I imagine that anyone who wants to seek 'the confidence of bankers' could have a surprise if I.

    Is it all consistent, sensible, ways to deal with this kind of issue that does not imply that users think reading the spirit?

    "You say, I think, it was a stupid move and that there is no harm in putting each search term all about braces? "'({WOMAN}) and (HAT {})' would be just as acceptable, as fast as the '(femme et chapeau)? »

    Fix.

  • How to optimize the performance of this query SQL

    Hello

    I need to find the age for each day, but I need for all previous dates in a single query. So I used the following query:

    Select trunc (sysdate) - level + 1 DATE

    trunc (sysdate) - level + 1 - created_date AGE

    elements

    connect by trunc (sysdate) - level + 1 - created_date > 0

    I get output (FOR the DATE and AGE) that is fine and correct:

    DATE AGE           

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

    6 JULY 15 22

    5 JULY 15 21

    4 JULY 15 20

    3 JULY 15 19

    2 JULY 15 18

    JULY 1, 15 17

    JUNE 30, 15 16

    JUNE 29, 15 15

    JUNE 28, 15 14

    JUNE 27, 15 13

    JUNE 26, 15 12

    25 JUNE 15 11

    24 JUNE 15 10

    Now I need to calculate the average age for each day and I added the average in the following query:

    Select trunc (sysdate) - level + 1 DATE .

    AVG (trunc (sysdate) - level + 1 - created_date) AVERAGE_AGE

    elements

    connect by trunc (sysdate) - level + 1 - created_date > 0

    Group of trunc (sysdate) - level + 1


    This query is correct? When I add the aggregate (avg) function to this query, it takes 1 hour to retrieve the data. When I remove the average request function that gives the result in 2 seconds? What is the solution to calculate the average without affecting performance? Help, please

    Maybe you are looking for something like this...

    SQL > ed
    A written file afiedt.buf

    1 with t (point, created_date) :)
    2 Select 1, date '' 2015-06-24 from all the double union
    3 select 2, date ' 2015-06-29 the Union double all the
    4 Select 3, date ' 2015-06-17' of the double
    5        )
    6  --
    7. end of test data
    8  --
    9. Select item
    10, trunc (sysdate) - level + 1 as dt
    11, trunc (sysdate) - level + 1-created_date age
    12, round (avg (trunc (sysdate) - level + 1 - created_date) on (trunc (sysdate) partition - level + 1), 2) as avg_in_day
    13 t
    14 connect by level<=>
    15-point point = prior
    sys_guid() 16 and prior is not null
    17 * order by 1.2
    SQL > /.
    POINT DT AGE AVG_IN_DAY
    ---------- ----------- ---------- ----------
    1 JUNE 24, 2015 0 3.5
    1 25 JUNE 2015 1 4.5
    1 26 JUNE 2015 2 5.5
    1 27 JUNE 2015 3 6.5
    1 28 JUNE 2015 4 7.5
    1 29 JUNE 2015 5 5.67


    1 30 JUNE 2015 6 6.67
    1 1 JULY 2015 7 7.67
    1-2 JULY 2015 8 8.67
    1-3 JULY 2015 9 9.67
    1 TO 4 JULY 2015 10 10.67
    1 5 JULY 2015 11 11.67
    1 6 JULY 2015 12 12.67
    2 JUNE 29, 2015 5.67 0
    2 30 JUNE 2015 1 6.67
    2 1 JULY 2015 2 7,67
    2 2 JULY 2015 3 8.67
    2-3 JULY 2015 4 9.67
    2-4 JULY 2015 5 10.67
    2-5 JULY 2015 6 11.67
    2-6 JULY 2015 7 12.67
    3 JUNE 17, 2015 0 0
    3 18 JUNE 2015 1 1
    3 19 JUNE 2015 2 2
    3 20 JUNE 2015 3 3
    3 21 JUNE 2015 4 4
    3 22 JUNE 2015 5 5
    3 23 JUNE 2015 6 6
    3 24 JUNE 2015 7 3.5
    3 25 JUNE 2015 8 4.5
    3 26 JUNE 2015 9 5.5
    3 27 JUNE 2015 10 6.5
    3 28 JUNE 2015 11 7.5
    3 29 JUNE 2015 12 5.67
    3 30 JUNE 2015 13 6.67
    3 1 JULY 2015 14 7.67
    3 2 JULY 2015 15 8.67
    3 3 JULY 2015 16 9.67
    3-4 JULY 2015 17 10.67
    3-5 JULY 2015 18 11.67
    3 6 JULY 2015 19 12.67

    41 selected lines.

  • What is the problem with this query?

    Hello

    I need some advice on how to change the following query (with perhaps some analytical function) to speed it up. Currently, it takes 6 + minutes. This query is executed in response to a request from the front-end application and 6 + min is certainly unacceptable.

    I am trying to provide as much information I can think, but if more information is needed, please let me know.

    I have a table called "wave_result". It contains millions of rows. PK is Wave_Id, Version_nbr, node_nbr and prod_nbr. For each 'wave_id + node_NBR + prod_nbr' there are several versions (version_nbr). In the following query, I try to extract a line with MAX version_nbr for combination of ' wave_id + node_NBR + prod_nbr.

    H3. Request:
    SELECT ip1.fnln_cat,
                ip1.sub_cat,
                ip1.bus_cat,
                NVL (SUM (ip1.lsu), 0) val
        FROM ideal_prod ip1, ideal_store s, wave_result wr
       WHERE  wr.wave_id = 51
             AND wr.prod_nbr = ip1.prod_nbr
             AND wr.wave_id = ip1.wave_id
             AND wr.version_nbr =
                    (SELECT MAX (wr1.version_nbr)
                       FROM wave_result wr1
                      WHERE   wr1.wave_id = wr.wave_id
                            AND wr1.node_nbr = wr.node_nbr
                            AND wr1.prod_nbr = wr.prod_nbr)
             AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
             AND s.wave_id = wr.wave_id
             AND s.node_nbr = wr.node_nbr 
    GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat
    H3. Rank of charges:
    ========
    "wave_result" is the largest table with millions of rows.
    Table                Total Rows       Rows for wave_id = 51
    Ideal_prod           188K             38K
    Ideal_store          3K               574
    Wave_result          90M              19M
    H3. Stats
    are updated almost daily by the DBA (not sure if that's a good or bad).

    H3. Explain the Plan:
    =========
    SELECT STATEMENT ALL_ROWS Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
         12 HASH GROUP BY Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
              11 VIEW VIEW SYS.VM_NWVW_2 Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
                   10 FILTER 
                        9 HASH GROUP BY Cost: 330,737 Bytes: 2,425,603 Cardinality: 14,881 
                             8 HASH JOIN Cost: 327,183 Bytes: 41,233,784 Cardinality: 252,968 
                                  1 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKIDEAL_STORE Cost: 4 Bytes: 13,202 Cardinality: 574 
                                  7 HASH JOIN Cost: 327,178 Bytes: 35,415,520 Cardinality: 252,968 
                                       5 HASH JOIN Cost: 198,619 Bytes: 18,764,328 Cardinality: 183,964 
                                            3 TABLE ACCESS BY INDEX ROWID TABLE APAPOPR.IDEAL_PROD Cost: 939 Bytes: 2,272,380 Cardinality: 37,873 
                                            4 TABLE ACCESS FULL TABLE APAPOPR.WAVE_RESULT Cost: 197,063 Bytes: 7,974,414 Cardinality: 189,867 
                                       6 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKWAVE_RESULT Cost: 82,467 Bytes: 721,495,854 Cardinality: 18,986,733 
    H3. Sample data:
    ===========
       For wave_id = 51
                     there are 28466854 rows in "wave_result" table
    
       For wave_id = 51 and node_nbr = '0201' and  prod_nbr = '0226960'
                     there are 3 rows in "wave_result" table
    H3. Version of database information are below to:
    =========================
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE            11.1.0.7.0                        Production
    TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Thank you very much!!

    Concerning
    For wave_id = 51
                     there are 28466854 rows in "wave_result" table
    
       For wave_id = 51 and node_nbr = '0201' and  prod_nbr = '0226960'
                     there are 3 rows in "wave_result" table
    

    As you mentioned that this particular request is called by a front screen, how different search criteria you get it to show on the front end?
    Assuming that if the user is searching just of wave_id = 51 which lines returns to 28466854, it is certainly not a good approach to go look up many records to put end Front end is very light and can not hold many records and will be finally the web server will throw off out of memory exception. Always a limit on the number of records that you retrieve from the database and display it on the front plane.
    OR
    The second case where the user makes a search by wave_id, node_nbr and prod_nbr, even if she returns to 3 lines, behind the scens, he still made a full scan on the wave_result table. If we go with analytical function, we can reduce a sweep of extra table on the wave_result table. Also the table has millions of lines and the max (version_nbr) seems to be a frequently used on this table sub query. While inserting a record into the table wave_result, you must probably have a calculated value that will tell you its value max and you will choose just the rank of this value, instead of at each time max(). something like below...

    SELECT ip1.fnln_cat,
                ip1.sub_cat,
                ip1.bus_cat,
                NVL (SUM (ip1.lsu), 0) val
        FROM ideal_prod ip1, ideal_store s, wave_result wr
       WHERE ipl.wave_id = 51
             AND wr.prod_nbr = ip1.prod_nbr
             AND wr.wave_id = ip1.wave_id
             AND wr.wave_id = s.wave_id
             AND wr.node_nbr = s.node_nbr
             AND wr.precomputed_max_value = 'MAX'
             AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
    GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat;
    
  • Is it possible to avoid the or in this sql?

    Hello

    I have a subquery to work which is givng me some performance issues... (I've changed the names of tables and columns).
    select h.name, h.age, h.sex, h.height, h.occupation
      from human h
     where h.newest = 'Y'
       and h.death_date is null
       and (i_department_ids is null or
           (i_department_ids is not null and
           h.unique_id in
           (select m.unikt_id
                from departments d
               where d.department_id like i_department_ids)) and
           (INSTR(i_apartment_numbers, aki.apartment_id) > 0 or
           i_apartment_numbers is null))
    i_department_ids and i_apartment_numbers can be null at the time, but not both at the same time, it is also checked. My problem is with two operators OR . As soon as I have the OR, a full scan is completed. A search can take as long as 13 seconds. Without the operators OR there 0,0062 dry. I use the OR operators because, if the input variable is zero, the condition must return True.

    If we scan a way I can avoid using the two operators OR , so I'll avoid the fulltable?

    Thank you very much

    William

    A shooting blind. Try this.

     select h.name, h.age, h.sex, h.height, h.occupation
       from human h
      where h.newest = 'Y'
        and h.death_date is null
        and case when i_department_ids is null then 1
                 when i_department_ids is not null and
                         h.unique_id in
                         (select m.unikt_id
                              from departments d
                             where d.department_id like i_department_ids))
                               and INSTR(nvl(i_apartment_numbers,aki.apartment_id), aki.apartment_id) > 0) then 1
                 else 0 end = 1
     
    

    Published by: Karthick_Arp on November 3, 2010 05:42

    Included the Toon conditino aswell.

  • How to display the values of this query? The type is XDB. XDB$ STRING_LIST_T

    Hi all

    If I run this query using a tool like developer PL/SQL (SQL window), the values are displayed as a Collection. Just click and see the results of the al.

    Select
    dbms_resconfig.getRepositoryResConfigPaths)
    Of
    Double;


    I want to know how to display these values using any tool of sqlplus (with dbms_output or something like that).

    How can I do? With the help of the table? Create a type?

    TKS

    user12083350 wrote:

    I want to know how to display these values using any tool of sqlplus (with dbms_output or something like that).

    SQL> select * from table(dbms_resconfig.getRepositoryResConfigPaths())
      2  /
    
    COLUMN_VALUE
    --------------------------------------------------------------------------------
    /sys/xs/userrc.xml
    /sys/xs/rolesetrc.xml
    /sys/xs/drolerc.xml
    /sys/xs/rolerc.xml
    /sys/xs/frolerc.xml
    /sys/xs/xdserc.xml
    /sys/xs/scrc.xml
    
    7 rows selected.
    
    SQL> 
    

    And in PL/SQL:

    SQL> declare
      2      v_list xdb$string_list_t := dbms_resconfig.getRepositoryResConfigPaths();
      3  begin
      4      for i in 1..v_list.count loop
      5        dbms_output.put_line(v_list(i));
      6      end loop;
      7  end;
      8  /
    /sys/xs/userrc.xml
    /sys/xs/rolesetrc.xml
    /sys/xs/drolerc.xml
    /sys/xs/rolerc.xml
    /sys/xs/frolerc.xml
    /sys/xs/xdserc.xml
    /sys/xs/scrc.xml
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

    Published by: Solomon Yakobson, April 24, 2010 15:04

  • What is the problem with this query? My head is numb!

    Can someone tell me why this request;

    < cfquery datasource = "manna_premier" name = "qGetstats" >
    SELECT the user name,
    UserFirstName,
    UserLastName,
    LastLogin,
    TotalLogins,
    UserZone,
    TM_Name
    USERS
    WHERE UserID = ' #. TM_log UserID # '.
    < / cfquery >

    generates this error message;

    Run database query error.

    [Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] Too few parameters. 1 expected.
    The error occurred in D:\Inetpub\mannapremier\TM_log_report2.cfm: line 28
    26 :         TM_Name
    27 : FROM Users
    28 : WHERE UserID = "#TM_log.UserID#"
    29 : </cfquery>
    30 : 
    

    SQLSTATE07002
    SQLSELECT the user ID, UserFirstName UserLastName, LastLogin, TotalLogins, UserZone, TM_Name FROM USERS WHERE UserID = '10120.
    VENDORERRORCODE-3010
    DATASOURCEmanna_premier

    I see that my variable WHERE comes through but the domain name is not working. I'm sure that the answer is obvious, but it drives me crazy!

    Help, please!

    I tried and got this result;

    No, you now use different data. Now, the user ID is empty, while she was 10120 first.

    The only problem seems to be double quotes. To check this, test with

    WHERE UserID = 10120
    

    I'm assuming that the userID field to be an integer. If it is text, then use single quotes (not!), as in

    WHERE UserID = '#TM_log.UserID#'
    
  • What is the problem with this query in the source

    A blank page is region 2. Region1: enter rec_no (-rec_no is varchar2) region2:hide and show that displays one record based on rec_ no region1 entered.
    The problem is that I get the following error

    ORA-06550: line 1, column 7: PLS-00428: an INTO clause in this SELECT statement

    Here's my simple query in a process of pl/sql
    Start
    Select rec_no, rec_name from mytable where rec_no = upper(:P16_rec_no);
    end;

    Why? The same query works under the sql command.

    what I'm trying to accompolish here, it is because he has given huge if I want to display hide also multiples, regions and allow users to update each region as a result. Help, please. It kills me that I just can't understand what is causing the problem to the query. Thank you.

    Hello

    The list is set to the field EMPLOYEE_ID itself? What is the primary key of the table? In my example, DEPTNO is the primary key and I used the element generated by the wizard page to display the list. The parameters of the Source of the item itself or the column DEPTNO and database so that the process "process line...". "to identify the updated row.

    Andy

  • How to get the result using this query?

    Hi using iam under query,

    WITH CTE (SNO, ID, PNT)

    AS

    (SELECT ROWNUM as SNO, TRANS_ID, VCN_NO OF)

    SELECT V.TRANS_ID, V.VCN_NO IN VSL_MOVES V

    WHERE V.END_TIME > = TRUNC (TO_DATE (: pStartDate, ' dd/MM/yy HH24')) AND V.END_TIME < = TRUNC (TO_DATE (: pEndDate, ' dd/MM/yy HH24'))

    AND V.MOVEMENT_TYPE_CODE NOT IN ORDER ("ATA") OF V.VCN_NO, V.END_TIME))

    SELECT ROWNUM as SNO, TAB. VESSEL_NAME, TAB. FLAG, TAB. IMO_NO, TAB. ARRIVED_DATE, TAB. F_ROM,

    NVL ((SELECT CASE WHEN VMS. MOVEMENT_TYPE_CODE = 'ATS' THEN (SELECT TO_CHAR (NBV. ATD, "DD/MM/YYYY HH24") OF PNTS WHERE NBV. DOC_NO = TAB. VCN_NO AND ROWNUM < = 1) WHEN VMS. MOVEMENT_TYPE_CODE = 'ATB' THEN (SELECT TO_CHAR (VBU. BRTH_ALL_FAST, "DD/MM/YYYY HH24") OF VSL_BERTH_UNBERTH VBU WHERE VBU. BERTH_TRANS_ID = VMS. TRANS_ID AND ROWNUM < = 1) END ELSE NULL VSL_MOVES VMS WHERE VMS. TRANS_ID = TAB. (T_ID),'-') Sailed_Date,.

    NVL ((SELECT CASE WHEN VMS. MOVEMENT_TYPE_CODE = 'ATS' THEN (SELECT P.PORT_NAME OF RRS, PORT_MASTER P WHERE P.PORT_CODE = PNT. VSL_NXT_PRT_CALL AND PNT. DOC_NO = TAB. VCN_NO) WHEN VMS. MOVEMENT_TYPE_CODE = 'ATB' THEN (SELECT CASE WHEN VBU. BERTH_CODE LIKE "% VOPK" AND THEN "VOPAK" WHAT VBU. BERTH_CODE AS "VSPM %" THEN "VOPAK" ELSE "POF" VBU VSL_BERTH_UNBERTH END WHERE VBU. BERTH_TRANS_ID = VMS. TRANS_ID AND ROWNUM < = 1) END ELSE NULL VSL_MOVES VMS WHERE VMS. TRANS_ID = TAB. (T_ID), "-") DESTINATION

    DE)

    SELECT

    VM. TRANS_ID,

    VM. VCN_NO,

    VM. MOVEMENT_TYPE_CODE,

    (SELECT PNT. VSL_NAME OF PNTS WHERE NBV. DOC_NO = VM. VCN_NO AND ROWNUM < = 1) VESSEL_NAME;

    (SELECT C.COUNTRY_NAME OF COUNTRY C, VESSEL_MASTER M WHERE C.COUNTRY_CODE = M.FLAG AND M.VSL_CODE = VM. VSL_CODE AND ROWNUM < = 1) AS FLAG,.

    (SELECT M.VSL_IMO_NO FROM VESSEL_MASTER M WHERE M.VSL_CODE = VM. VSL_CODE AND ROWNUM < = 1) IMO_NO;

    TO_CHAR (VM. END_TIME, "DD/MM/YYYY HH24") ARRIVED_DATE,.

    WHEN VM BOX. MOVEMENT_TYPE_CODE = 'STA' THEN (SELECT P.PORT_NAME FROM RRS, PORT_MASTER P WHERE P.PORT_CODE = PNT. LST_PORT_CALL AND PNT. DOC_NO = VM. VCN_NO AND ROWNUM < = 1) WHEN VM. MOVEMENT_TYPE_CODE = 'UTA' THEN (SELECT VB. VSL_BERTH_UNBERTH VB BERTH_CODE WHERE VB. UNBERTH_TRANS_ID = VM. TRANS_ID AND ROWNUM < = 1) END F_ROM.

    --(SELECT T2.ID DELE DE CTE T1 JOIN CTE T2 SUR T1.) SNO = T2. SNO + 1 WHERE T1.ID = VM. TRANS_ID AND T1. NBV = VM. VCN_NO AND T2. NBV = VM. ATD VCN_NO)

    (SELECT T1.ID CTE T1 WHERE SNO = (SELECT T2. SNO + 1 ETC T2 WHERE T2.ID = VM. TRANS_ID AND T2. NBV = VM. T_ID VCN_NO))

    OF VSL_MOVES VM

    WHERE (VM. End_time > = TRUNC (TO_DATE (: pStartDate, ' dd/MM/yy HH24')) AND VM. End_time < = TRUNC (TO_DATE (: pEndDate, ' dd/MM/yy HH24')) or

    ((CASE WHEN VMS. MOVEMENT_TYPE_CODE = 'ATS' THEN (SELECT TO_CHAR (NBV. ATD, "DD/MM/YYYY HH24") OF PNTS WHERE NBV. DOC_NO = TAB. VCN_NO AND ROWNUM < = 1) WHEN VMS. MOVEMENT_TYPE_CODE = 'ATB' THEN (SELECT TO_CHAR (VBU. BRTH_ALL_FAST, "DD/MM/YYYY HH24") OF VSL_BERTH_UNBERTH VBU WHERE VBU. BERTH_TRANS_ID = VMS. TRANS_ID AND ROWNUM < = 1) END ELSE NULL VSL_MOVES VMS WHERE VMS. TRANS_ID = TAB. Saileddate T_ID)) > = TRUNC (TO_DATE (: pStartDate, ' dd/MM/yy HH24')) and

    (CASE WHEN VMS. MOVEMENT_TYPE_CODE = 'ATS' THEN (SELECT TO_CHAR (NBV. ATD, "DD/MM/YYYY HH24") OF PNTS WHERE NBV. DOC_NO = TAB. VCN_NO AND ROWNUM < = 1) WHEN VMS. MOVEMENT_TYPE_CODE = 'ATB' THEN (SELECT TO_CHAR (VBU. BRTH_ALL_FAST, "DD/MM/YYYY HH24") OF VSL_BERTH_UNBERTH VBU WHERE VBU. BERTH_TRANS_ID = VMS. TRANS_ID AND ROWNUM < = 1) END ELSE NULL VSL_MOVES VMS WHERE VMS. TRANS_ID = TAB. T_ID) saileddate) < = TRUNC (TO_DATE (: pEndDate, ' dd/MM/yy HH24')))

    --(Sailed_Date > = TRUNC (TO_DATE (: pStartDate, ' dd/MM/yy HH24 ')) AND Sailed_Date < = TRUNC (TO_DATE (: pEndDate, ' dd/MM/yy HH24')))

    AND VM. MOVEMENT_TYPE_CODE IN ('STA', "UTA")

    ) TAB

    now my Question is should I include Sailed date also starttime and endtime (ex: date range of pStartDate and pEndDate I need to display the date sailed respected records)

    I mean the problem is solved, I found the solution

    docks of pof-

    WITH CTE (SL, VCN_NO, VESSEL_NAME, FLAG, IMO_NO, ARRIVED, FROM_, MOVEMENT_TYPE_, NEXT_MOVE, SAILED_DATE, DESTINATION, FID, TID)

    AS

    (SELECT T1.*,

    WHEN T1 BOX. FROM_ = 'POF' THEN 1 OTHER 2 END FID,

    WHEN T1 BOX. DESTINATION = "POF" THEN 1 OTHER 2 END TID

    Of

    (

    SELECT ROW_NUMBER() OVER (PARTITION OF VM. VCN_NO ORDER BY VB. (SL BRTH_ALL_FAST),

    VM. VCN_NO,

    (SELECT M.VSL_NAME FROM VESSEL_MASTER M WHERE M.VSL_CODE = VM. VESSEL_NAME VSL_CODE),

    (SELECT C.COUNTRY_NAME OF COUNTRY C, VESSEL_MASTER M WHERE C.COUNTRY_CODE = M.FLAG AND M.VSL_CODE = VM. VSL_CODE AND ROWNUM< =1="" )="" as="">

    (SELECT M.VSL_IMO_NO FROM VESSEL_MASTER M WHERE M.VSL_CODE = VM. IMO_NO VSL_CODE),

    VB. BRTH_ALL_FAST HAS ARRIVED,

    (CASE WHEN VM. MOVEMENT_TYPE_CODE = 'ATB' THEN 'ANCHORAGE' WHAT VM. MOVEMENT_TYPE_CODE = "LTB" THEN 'LAND' WHEN VM. MOVEMENT_TYPE_CODE = "BTB" AND (SELECT TT1. VSL_MOVES TT, VSL_BERTH_UNBERTH TT1 BERTH_CODE WHERE TT. TRANS_ID = TT1. BERTH_TRANS_ID AND TT. VCN_NO = VM. VCN_NO AND TT1. UNBERTH_TRANS_ID = VB. BERTH_TRANS_ID) (SELECT WB. BERTH_MASTER BM BERTH_CODE WHERE BM. QUAY_CODE NOT IN ("VOPAK", "SPM")) THEN 'POF' WHEN VM. MOVEMENT_TYPE_CODE = "BTB" AND (SELECT TT1. VSL_MOVES TT, VSL_BERTH_UNBERTH TT1 BERTH_CODE WHERE TT. TRANS_ID = TT1. BERTH_TRANS_ID AND TT. VCN_NO = VM. VCN_NO AND TT1. UNBERTH_TRANS_ID = VB. BERTH_TRANS_ID) (SELECT WB. BERTH_MASTER BM BERTH_CODE WHERE BM. QUAY_CODE IN ("VOPAK", "SPM")) THEN "VOPAK" OTHER (SELECT P.PORT_NAME FROM RRS, P PORT_MASTER WHERE P.PORT_CODE = PNT. LST_PORT_CALL AND PNT. DOC_NO = VM. FROM_ VCN_NO END)).

    VM. MOVEMENT_TYPE_CODE,

    (SELECT THE VIRTUAL COMPUTERS. VSL_MOVES VMS MOVEMENT_TYPE_CODE WHERE VMS. TRANS_ID = VB. NEXT_MOVE UNBERTH_TRANS_ID),

    VB. UB_LST_LNE_CASTOFF SAILED_DATE,

    NVL ((SELECT CASE WHEN VMS. MOVEMENT_TYPE_CODE = 'UTA' THEN 'ANCHORAGE' WHAT VMS. MOVEMENT_TYPE_CODE = 'BTL' THEN 'LAND' WHEN VMS. MOVEMENT_TYPE_CODE = "UTS" THEN (SELECT P.PORT_NAME FROM RRS, PORT_MASTER P WHERE P.PORT_CODE = PNT. VSL_NXT_PRT_CALL AND PNT. DOC_NO = VMS. VCN_NO) WHEN VMS. MOVEMENT_TYPE_CODE = "BTB" AND (SELECT TT1. VSL_MOVES TT, VSL_BERTH_UNBERTH TT1 BERTH_CODE WHERE TT. TRANS_ID = TT1. BERTH_TRANS_ID AND TT. VCN_NO = VM. VCN_NO AND TT1. BERTH_TRANS_ID = VMS. TRANS_ID) (SELECT WB. BERTH_MASTER BM BERTH_CODE WHERE BM. QUAY_CODE NOT IN ("VOPAK", "SPM")) THEN 'POF' WHEN VMS. MOVEMENT_TYPE_CODE = "BTB" AND (SELECT TT1. VSL_MOVES TT, VSL_BERTH_UNBERTH TT1 BERTH_CODE WHERE TT. TRANS_ID = TT1. BERTH_TRANS_ID AND TT. VCN_NO = VM. VCN_NO AND TT1. BERTH_TRANS_ID = VMS. TRANS_ID) (SELECT WB. BERTH_MASTER BM BERTH_CODE WHERE BM. QUAY_CODE IN ("VOPAK", "SPM")) THEN "VOPAK" OTHERWISE NULL END VSL_MOVES VMS WHERE VB. UNBERTH_TRANS_ID = VMS. (TRANS_ID), "-") DESTINATION

    OF VM, VSL_BERTH_UNBERTH VB VSL_MOVES WHERE (VM. TRANS_ID = VB. BERTH_TRANS_ID)

    AND VM. MOVEMENT_TYPE_CODE LIKE '% TB '.

    AND ((VB. BRTH_ALL_FAST > = TO_TIMESTAMP(:pStartDate,'DD/MM/YYYY HH24:MI') AND VB. BRTH_ALL_FAST<= to_timestamp(:penddate,'dd/mm/yyyy="">

    OR (VB. UB_LST_LNE_CASTOFF > = TO_TIMESTAMP(:pStartDate,'DD/MM/YYYY HH24:MI') AND VB. UB_LST_LNE_CASTOFF<= to_timestamp(:penddate,'dd/mm/yyyy="" hh24:mi'))="">

    AND VB. BERTH_CODE (SELECT WB. BERTH_MASTER BM BERTH_CODE WHERE BM. QUAY_CODE NOT IN ("VOPAK", "SPM"))

    - AND VM. VCN_NO = 201510336

    ORDER OF VB. BRTH_ALL_FAST

    ) T1

    )

    Select rownum AS SNO, tab2.* of)

    SELECT

    TAB1. VCN_NO, TAB1. VESSEL_NAME, TAB1. FLAG, TAB1. IMO_NO,

    NVL (BOX WHEN TAB1. HAS ARRIVED< to_timestamp(:pstartdate,'dd/mm/yyyy="" hh24:mi')="" then="" '----------'="" else="" to_char(tab1.arrived,'dd/mm/yyyy="" hh24:mi')="" end,'----------')="">

    NVL (BOX WHEN TAB1. HAS ARRIVED< to_timestamp(:pstartdate,'dd/mm/yyyy="" hh24:mi')="" then="" '----------'="" else="" (select="" t2.from_="" from="" cte="" t2="" where="" t2.sl="TAB1.FROM_" and="" t2.vcn_no="TAB1.VCN_NO)" end,'----------'="">

    NVL (CASE WHEN (SELECT T2. DESTINATION OF THE CTE T2 WHERE T2.SL = TAB1. DEST AND T2. VCN_NO = TAB1. VCN_NO) = 'POF' THEN '-' ANOTHER BOX WHEN TAB1. SAILED_DATE > TO_TIMESTAMP (: pEndDate, ' DD/MM/YYYY HH24') THEN '-' ELSE TO_CHAR (TAB1. (SAILED_DATE, "DD/MM/YYYY HH24") A PIECE,'-') SAILED_DATE,.

    NVL (BOX WHEN TAB1. SAILED_DATE > TO_TIMESTAMP (: pEndDate, ' DD/MM/YYYY HH24') THEN '-' ELSE (SELECT CASE WHEN T2. DESTINATION = 'POF' THEN '-' ANOTHER T2. THE END OF THE DESTINATION OF THE CTE T2 WHERE T2.SL = TAB1. DEST AND T2. VCN_NO = TAB1. (END OF VCN_NO), "-") DESTINATION

    DE)

    SELECT THE TAB. VCN_NO, TAB. VESSEL_NAME, TAB. FLAG, TAB. IMO_NO,

    MIN (TAB. HAPPENED) ARRIVED,

    MIN (TAB.SL) FROM_,

    MAX (TAB. SAILED_DATE SAILED_DATE),

    MAX (TAB.SL) DEST,

    TAB. SNO

    DE)

    SELECT T1.*,

    WHEN T1 BOX. FID = 2 AND T1. TID = 1 THEN 1 WHEN T1. FID = 1 AND T1. TID = 2 THEN 1 WHEN T1. FID = 1 AND T1. TID = 1 THEN 0

    WHEN T1. FID = 2 AND T1. TID = ROWNUM THEN 2 + 1 END OF ANOTHER 3 SNO

    T1 ETC

    ) GROUP OF TABS BY TABS. VCN_NO, TAB. VESSEL_NAME, TAB. FLAG, TAB. IMO_NO, TAB. SNO

    ) TAB1 WHERE TAB1. SNO<>0

    ) tab2

  • How to use the case for this query.

    I got this name from the Employee table.
    columns...

    EmpId,
    EmpType,
    Join date,
    Date of resignation

    Now in EmpType it can be either 'P' OR 'C '.

    So I want to check if the EmpTYpe is 'P' then joiningdate must not be null
    and if the EmpType is 'C' then resignation date must not be null.

    So only want to employee records.
    Help, please.

    Select * from employee
    where (employeetype = 'c' and joinngdate is not null)
    or (employeetype = 'p' and resigndate is not null)

  • Get the max of this query

    DB version: 10 gr 2

    My query below is a union of two queries max. Currently, it returns two rows.
    select max(to_timestamp(to_char(END_EFFECTIVE_DATE,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')) 
    from SHIP_DTL
    where SHIP_DTL.IS_ENABLED = 1 AND SHIP_DTL.IS_DELETED = 0 
    AND COMPANY_ID =1
    and cost_event_id=1 and END_EFFECTIVE_DATE is not null
    union
    select max(to_timestamp(to_char(START_EFFECTIVE_DATE,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')) from SHIP_DTL
    where SHIP_DTL.IS_ENABLED = 1 AND SHIP_DTL.IS_DELETED = 0 AND COMPANY_ID =1
    and cost_event_id=1 and END_EFFECTIVE_DATE is null;
    
    MAX(TO_TIMESTAMP(TO_CHAR(END_EFFECTIVE_DATE,'YYYY-MM-DDHH24:MI:SS'),'YYYY-M
    ---------------------------------------------------------------------------
    09-12-01 05:39:00.000000000
    09-12-30 06:55:00.000000000
    I want to get the most out of these two lines. So, I tried the following query using double. But I get the error message
    SQL> select max (select max(to_timestamp(to_char(END_EFFECTIVE_DATE,'YYYY-MM-DD HH24:MI:SS'),'YYYY-M
    M-DD HH24:MI:SS')) 
      2  from SHIP_DTL
      3  where SHIP_DTL.IS_ENABLED = 1 AND SHIP_DTL.IS_DELETED = 0 
      4  AND COMPANY_ID =1
      5  and cost_event_id=1 and END_EFFECTIVE_DATE is not null
      6  union
      7  select max(to_timestamp(to_char(START_EFFECTIVE_DATE,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:
    MI:SS')) from SHIP_DTL
      8  where SHIP_DTL.IS_ENABLED = 1 AND SHIP_DTL.IS_DELETED = 0 AND COMPANY
    _ID =1
      9  and cost_event_id=1 and END_EFFECTIVE_DATE is null) from dual;
    select max (select max(to_timestamp(to_char(END_EFFECTIVE_DATE,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD 
                *
    ERROR at line 1:
    ORA-00936: missing expression
    What I'm doing wrong here?
    select max(dt) from (
     SELECT MAX(to_timestamp(TO_CHAR(END_EFFECTIVE_DATE,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')) dt
       FROM SHIP_DTL
      WHERE SHIP_DTL.IS_ENABLED = 1
    AND SHIP_DTL.IS_DELETED     = 0
    AND COMPANY_ID              =1
    AND cost_event_id           =1
    AND END_EFFECTIVE_DATE     IS NOT NULL
      UNION
    SELECT MAX(to_timestamp(TO_CHAR(START_EFFECTIVE_DATE,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS'))
       FROM SHIP_DTL
      WHERE SHIP_DTL.IS_ENABLED = 1
    AND SHIP_DTL.IS_DELETED     = 0
    AND COMPANY_ID              =1
    AND cost_event_id           =1
    AND END_EFFECTIVE_DATE     IS NULL
    )
    

    put in a sub query

    Ravi Kumar

  • How can I set up my printer with the internet to avoid the impression in this tiny print and language I don't recognize?

    I used to be able to print very well and then something happened and I don't know how to correct it. Not only, it prints in very small font and lettering I do not recognize but also wants to print many pages, that I'm not. Thx for all help to correct.

    Hello

    · What is the number and model of the printer?

    · You want to print Web pages?

    · Were there changes before the show?

    1 if the font is small when you print from Web pages, and then try to increase the size of the text on the Web page, change the size of text larger or largest.

    a. in Internet Explorer, open the Web page from which to print.

    b. on the view menu, point to text size.

    c. click the biggest or largest to enlarge the size of text.

    d. print the Web page again.

    2. you can also run the troubleshooter and check if that helps: printer in Windows problems: http://windows.microsoft.com/en-us/windows/help/printer-problems-in-windows

  • Please give me the answer to this query

    Hi all

    Select to_char (123.5, 'fm$ 99999.00') of double

    When I run it I get a result of $123,50

    I want to use other characters like speacial @, * instead of $

    But I am getting error invalid identifier if I use any other speacial character that $

    Can I use? otherwise what would be the reason

    appreciate for the quick reply

    Thanks in advance

    as?

    select replace(to_char(123.5,'fm$99999.00'),'$','@') from dual
    
    @123.50
    

Maybe you are looking for