The simple query help

Hello! I have a simple request: NO of ROAD_TYPE = "RAMP" or NO FUNC_CODE = 7 FUNC_CODE or NOT = 0 or NOT FUNC_CODE = NULL, each element of the query by itself without problem, tracks, but linked together in this way with the GOLD, one of them opts on. What I am doing wrong?

It's the difference between OR and and.

Think about this simple example

Where Column != A or Column != B.

Excluding the Null handling, it's true. Because for the first condition, it will be true for all but one, and the second condition will be true for A. You need an AND, not a RC.

For simplicity and readability without doubt, use an In operator, and group together them. It would therefore be:

Where Road_Type != 'RAMP' and Func_Code Not In('0, 7) and Func_Code is not Null

Tags: Database

Similar Questions

  • The ROWNUM query help

    SELECT * FROM (SELECT A.SSN, C.CLAIM_SEQ, A.FIRST, A.MID, A.LAST, C.CLAIM_DT, C.INSERT_DT, C.CLAIM_STAT,
    RN C.ISSUE_CDE, B.UCX_UCFE, B.TRAPOSS, B.DUAPOSS, C.AGENT_ID, C.CONFNUM, ROWNUM
    THE APPLICANT HAS, CLMTELIG B, UICLAIMS C
    WHERE A.CLMT_SEQ = B.CLMT_SEQ AND B.CLMT_SEQ = C.CLMT_SEQ) HAS
    WHERE A.RN > = 100 AND A.RN < = 200

    If you need high-end of for example: 100 records I get them...

    But when I add the date column insert in this query to get the same range

    SELECT * FROM (SELECT A.SSN, C.CLAIM_SEQ, A.FIRST, A.MID, A.LAST, C.CLAIM_DT, C.INSERT_DT, C.CLAIM_STAT,
    RN C.ISSUE_CDE, B.UCX_UCFE, B.TRAPOSS, B.DUAPOSS, C.AGENT_ID, C.CONFNUM, ROWNUM
    THE APPLICANT HAS, CLMTELIG B, UICLAIMS C
    WHERE A.CLMT_SEQ = B.CLMT_SEQ AND B.CLMT_SEQ = C.CLMT_SEQ) HAS
    WHEN TRUNC (INSERT_DT) BETWEEN ' 01-AUG-09' AND '' 02-SEP-09
    AND A.RN > = 100 AND A.RN < = 200

    This 100 and 200 are actually the bind variable: p_range1 and: p_range2
    rownum > =: p_range1 AND rownum < =: p_range2

    The user can enter any beach, as he has 300 to 500 should get rownum between 300 and 500 records.

    Any help is appreciated...

    Thanks in advance...

    Hello

    Use the analytical ROW_NUMBER function instead of ROWNUM.

    For example:

    SELECT  *
    FROM     (   SELECT  A.SSN, C.CLAIM_SEQ, A.FIRST, A.MID, A.LAST
             ,         C.CLAIM_DT, C.INSERT_DT, C.CLAIM_STAT
             ,         C.ISSUE_CDE, B.UCX_UCFE, B.TRAPOSS, B.DUAPOSS, C.AGENT_ID
             ,         C.CONFNUM
             ,         ROW_NUMBER () OVER (ORDER BY ...)     -- Use whatever column or columns you want
                                         AS rn
             FROM    CLAIMANT   A
             ,         CLMTELIG   B
             ,         UICLAIMS   C
             WHERE   A.CLMT_SEQ = B.CLMT_SEQ
             AND         B.CLMT_SEQ = C.CLMT_SEQ
         ) A
    WHERE      TRUNC (INSERT_DT) BETWEEN '01-SEP-09'
                           AND       '02-SEP-09'
    AND     A.RN             BETWEEN  :p_range1
                     AND        :p_range2
    ;
    

    In the ORDER BY clause Analytics, put expressions that determine the order. You can use ASC or DESC after each expression as an ORDER BY in the query clause.
    In the query that you have posted, rn has been affected in no particulare order. If that's what you really want, use a constant in analytics ORDER BY clause, like this:

    ...         ,         ROW_NUMBER () OVER (ORDER BY  0)
    

    You must use an ORDER byclause with ROW_NUMBER.

    If you really want to use ROWNUM, assign ROWNUM in a subquery (give it an alias like r_num), then to a query of great, have the State "WHERE the r_num BETWEEN: p_range1 AND: p_range2.

    Note that you query can produce rewer 101 lines, before even the last page. In fact, it can produce no line. The condition in the main query "WHERE TRUNC (INSERT_DT) BETWEEN" is applied after that rn is assigned, so, although the 101 lines meet the requirement on the rn, they can all be excluded by the condition on insert_date. Move condition on insert_date in the subquery if you want to change this.

    Moreover, it is a Request of Pagination .

    Published by: Frank Kulash, 21 May 2010 14:39
    Added example.

  • Problem with the simple query.

    Hi all

    I am facing problem with the query below

    Select A.COL1, A.COL2

    B.COL1, B.COL2

    FROM TABLE1 A

    TABLE 1 B

    WHERE A.header = '123'

    AND B.header = '123'

    AND nvl (A.COL6, 'ABC') = 'ABC '.

    AND NVL (B.COL6, 'DEF') = 'DEF '.

    Basically, my requiremenyt is: I have only one table, TABLE1 here, which has a line two lines (for the same header) as "ABC" and another is "DEF". Table 1 has two columns (col1, col2) that should be displayed for both lines.

    When the header has two records in table1 top query works. and but if I do not have a record for any header example there are a record for "abc" in col6 only. so my query above does not work because there is no record for 'DEF' in col6. But I want to again request to fecth the output (for b.col1 and b.col2 should have null values)

    could you pls suggest me how to get the 4 columns.

    Thanks in advance

    Kind regards

    UVA.

    Try to place the status of outer join on column: analytical_criterion_code as

    and nvl (AUDIT.analytical_criterion_code, 'AUDIT2') = 'verification2. '

    .

    .

    and nvl (TRANS.analytical_criterion_code, 'TRANS2') = 'TRANS2.

    In the sub query based on the opinions that you have given in post # 1, although there is no value "DEF * ' for col6 due to the condition of outer join on b.col6 (+) line is extracted with b.col [1,2,3] as NULL values. Try to remove the (+) sign b.col6 and test.

    with t as)

    Select 111 col1, col2 'aaa', 'ABC' col6 123 header of all the double union

    Select 222 'bbb', 'DEF' col6, 123 double header

    )

    q as (select 123 double header)

    Select A.COL1, A.COL2, A.COL6

    B.COL1, B.COL2, b.COL6

    q.header

    T a

    t b

    q

    where a.col6 (+) = 'ABC '.

    and b.col6 (+) = "DEF."

    and q.header = a.header (+)

    and q.header = b.header (+)

  • Better way to write the simple query?

    I'm trying to get the date of 'busy' max 'mansion '.

    It is an example, I imagined, since I can't post our actual data. The following query works, but is their path easier.
    CREATE TABLE TEST_TABLE (  
    LOAN_NUMBER                 VARCHAR2(15 Byte),
    UN_ID                       NUMBER,
    CHANGE_DATE                 DATE,
    PROP_TYPE                   VARCHAR2(25 Byte),
    OCCSTAT                     VARCHAR2(25 Byte)
    ); 
    COMMIT;
    
    
    INSERT INTO TEST_TABLE VALUES (123456,  1,'01-JAN-09','Tent','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  2,'01-FEB-09','Shack','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  3,'01-JUN-08','Single Family','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  4,'01-OCT-08','Single Family Plus','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  5,'01-DEC-08','Mansion','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  6,'05-JAN-09','Mansion','Unoccupied');
    COMMIT;
    Reason, I take the ID's for the second join because I know that the ID max = max.
    select     
    i2.UN_ID,
    i2.CHANGE_DATE,
    i2.PROP_TYPE,
    i2.OCCSTAT
    from 
    (
        select 
            distinct(LOAN_NUMBER) AS "LOAN_ID", 
            max(UN_ID) AS "ID_MAX"
        from(
        select 
            LOAN_NUMBER,
            UN_ID
      from
            TEST_TABLE
        where OCCSTAT = 'Occupied'
        group by LOAN_NUMBER, UN_ID
        ) 
        group by LOAN_NUMBER
    )i
    left join TEST_TABLE i2 on i.ID_MAX = i2.UN_ID
    easier way without the second join?

    Thanks in advance.

    R

    Try this query, it should be equivalent to your:

    select UN_ID, CHANGE_DATE, PROP_TYPE, OCCSTAT
    from (
        select LOAN_NUMBER, UN_ID, CHANGE_DATE, PROP_TYPE, OCCSTAT, rank() over(partition by LOAN_NUMBER order by un_id desc) rn
        from test_table
         where OCCSTAT = 'Occupied'
    )
    where rn=1
    

    Max

  • Helps the simple query XPath in OSB

    Hello!

    I try to extract a part of XML with Oracle Service Bus using XPath message, but I can't find the way to make

    For testing purposes, I initialize a variable 'test' with an action of assignment with the following content:

    < Country > < country > < COUNTRY > ARE < / COUNTRIES > < S EU_COUNTRY > < / EU_COUNTRY > < Spain NUMBER > < / NUMBER > < ID > 1 < /ID > < country > < / country >

    Can I use following code to access the COUNTRY element but I get blank result:

    $test, Countries, Country, COUNTRY / text)

    I'm rather new to XPath, but I think that this expression should work.

    Could someone give me some advice?

    Thank you.

    Published by: user542345 on June 15, 2011 09:06

    Use

    $test / country/COUNTRY/text)

  • simple query help :)

    I have table with date, customer number, salary... Now, I want to extract the total number of client whose salary is between 2000 and 3000 and deposited consistantly for the last 6 months.
    Can someone help me with this...

    user12183668 wrote:
    I used your query... its working well... but there are a few County for the date (NTC) which I am less than 6... .and I want to exclude these documents at the level of the query.

    How can I do this

    By encapsulating the query as an interior view, something in this way:

    select *
      from (
    select
     empno
    ,count(distinct trunc(hiredate,'MM')) cnt
    from emp
    where
    sal between 2000 and 3000
    and
    hiredate >= add_months (trunc(sysdate, 'MM'), -5 )
    group by empno
    ) a
    where a.cnt = 6;
    
  • How to make the simple query for this scenario... ?

    Hello:

    Dummy table provided for simplicity.

    It's my database table (Table_A)

    Date1 | Plane1 | Category | Duration | Fees
    01/01/2011 | A | Gold | 5. 2
    01/01/2011 | C | Money | 4. 11
    01/01/2011 | B | Gold | 6. 2
    01/01/2011 | D | Gold | 2. 4
    01/01/2011 | B | Gold | 3. 5
    01/01/2011 | A | Money | 4. 8
    01/01/2011 | B | Gold | 1. 3

    I need to write a query to get the result below:

    Date1 | Plane1 | Sum_Duration | Sum_Charge | Sum_Gold_Duration | Sum_Gold_Charge | Sum_Silver_Duration | Sum_Silver_Charge
    01/01/2011 | A | 9. 10. 5. 2. 4. 8
    01/01/2011 | B | 10. 10. 10. 10. 0 | 0
    01/01/2011 | C | 4. 11. 0 | 0 | 4. 11
    01/01/2011 | D | 2. 4. 2. 4. 0 | 0

    This query will provide the 1st four columns:

    SELECT Date1,
    base1,
    Sum (Duration) Sum_Duration,
    Sum (load) Sum_Charge
    FROM TABLE_A
    GROUP BY date1, rarateplan

    But I need to know how to get the rest of the columns (i.e. Summary according to categories; from 5 to 8 columns)? Is this can be done in a single query without writing subqueries?

    Please let me know, (with code), the best way.

    Thank you-
    Tanvir

    Use like this:

    SELECT Date1,
    base1,
    Sum (Duration) Sum_Duration,
    Sum (load) Sum_Charge,
    SUM (decode(Category,'Gold',duration,0)) Sum_Gold_Duration,
    SUM (decode(Category,'Gold',charge,0)) Sum_Gold_charge,
    SUM (decode(Category,'Silver',duration,0)) Sum_Silver_Duration,
    SUM (decode(Category,'Silver',charge,0)) Sum_Silver_charge
    FROM TABLE_A
    GROUP BY date1, rarateplan

    Published by: SANT007 on August 11, 2011 11:04

  • Decode the simple query

    Decode the query
    Simplified version of the query below.

    SELECT
    d.REG,
    d.DP,
    c.CHANNEL
    Of
    CUSTOMER c,.
    ACCOUNT d
    WHERE c.ID = d.ID
    D.REG GROUP, d.DP, c.CHANNEL


    Channel field in the Customer Table contains several store ID (1 Store, tray 2, tray 3, store 4 etc.) - basically, I want to use decode on the channel field so that instead of all the store ID being issued what is fate of the channel are
    Store 1 = "big".
    Store 2 = 'average '.
    Store 3 = "Small".
    All other stores = 'other '.

    Where the decode to insert statement and what should be the format - attempt below
    DECODE (c.CHANNEL, "keep 1, 'Big', ' Store 2', 'Medium', 'Store' 3', small ', 'Other' ') of

    Hello

    This should be what you are looking for:

    SELECT   d.REG,
             d.DP,
             DECODE (c.CHANNEL, 'Store 1','Large', 'Store 2','Medium', 'Store 3','Small', 'Other') Channel
    FROM     CUSTOMER c,
             ACCOUNT d
    WHERE    c.ID = d.ID
    GROUP BY d.REG,
             d.DP,
             c.CHANNEL
    

    City where to move them in decoding...

  • The UPDATE query help

    I'm on 10G.

    Something is weird. Each customer_id to table X is from the subquery. Basically by train to fill the column of SUSPICION in X to a value of H when there are name/store is from the subquery using the customer_id.

    When I run just the subquery returns 287 matches (and all these 287 X is), but when I try to UPDATE X only update the 260 H lines, but should 287? 27 never update, why? The customer_id are distinct or not NULL values.

    What I am doing wrong?

    Like I said I have selected everything from (subquery), I pasted in Excel. I chose all the customer_ids of X and when I do a VLOOKUP, everything matches, but the query updates only 260 and 287 not? :- )


    UPDATE PROSPECTS_FEB_TEST X
    SET X.HINT = 'H' WHERE X.customer_id IN

    (SELECT a.customer_id
    PROSPECTS OF A, B CONNECTED
    WHERE B.LAST_NAME = A.NAME_LAST
    AND B.FIRST_NAME = A.NAME_FIRST
    AND B.STORE = A.STORE);

    What you get from this?

    SELECT COUNT(DISTINCT a.customer_id)
    FROM prospects a, connected b
    WHERE b.last_name = a.name_last and
          b.first_name = a.name_first and
          b.store = a.store
    

    Is customer_id a numeric field or a varchar2? If it's a varchar2, could their space having in one of the other tables?

    John

  • The SQL query help

    with t as

    (

    Select to_date (January 1, 2014 "," dd-mon-yyyy ') col1, 'a' col2, col3 1.04 by union double all the

    Select to_date (5 January 2014 ',' mon-dd-yyyy "") col1, 'a' col2, col3 1.02 Union double all the

    Select to_date (8 January 2014 ',' mon-dd-yyyy "") col1, col2, col3 1.01 Union ' b' double all the

    Select to_date (January 10, 2014 "," dd-mon-yyyy "") col1, col2, col3 1.05 Union ' b' double all the

    Select to_date (January 10, 2014 "," dd-mon-yyyy "") col1, col2, col3 2.00 Union ' b' double all the

    Select to_date (January 10, 2014 "," dd-mon-yyyy "") col1, col2 'c', col3 3.05 Union double all the

    Select to_date (January 14, 2014 "," dd-mon-yyyy "") col1, col2, col3 6.00 Union ' b' double all the

    Select to_date (15 January 2014 "," dd-mon-yyyy "") col1, col2, col3 6.10 Union ' b' double all the

    Select to_date (15 January 2014 "," dd-mon-yyyy ') col1, col2, col3 6.05 of the double ' c'

    )

    Select t.*

    t;

    OUTPUT:

    COL1 COL2 COL3

    01/01/2014 by 1.04

    05/01/2014 a 1.02

    08/01/2014 b 1.01

    10/01/2014 b 1.05

    10/01/2014 b 2

    10/01/2014 c 3.05

    14/01/2014 b 6

    15/01/2014 b 6.1

    15/01/2014 c 6.5

    Required power must be:

    COL1 COL2 COL3

    01/01/2014 by 1.04

    05/01/2014 a 1.02

    08/01/2014 b 1.01

    10/01/2014 b 1.01

    10/01/2014 b 1.01

    10/01/2014 c 1.01

    14/01/2014 b 6

    15/01/2014 b 6

    15/01/2014 c 6

    If we found the dates duplicate, we need update COL3 value with the previous value of max (date) value COL3.

    Please save my life!

    Hello

    Try this:

    WITH
    t AS
    (SELECT to_date (January 1, 2014 "," dd-mon-yyyy ') col1, 'a' col2, 1.04 col3 FROM dual)
    UNION ALL
    SELECT to_date (5 January 2014 ',' mon-dd-yyyy "") col1, 'a' col2, 1.02 col3 FROM dual
    UNION ALL
    SELECT to_date (8 January 2014 ',' mon-dd-yyyy "") col1, col2 'b', 1.01 col3 FROM dual
    UNION ALL
    SELECT to_date (January 10, 2014 ',' mon-dd-yyyy "") col1, col2 'b', 1.05 col3 FROM dual
    UNION ALL
    SELECT to_date (January 10, 2014 ',' mon-dd-yyyy "") col1, col2 'b', 2,00 col3 FROM dual
    UNION ALL
    SELECT to_date (January 10, 2014 ',' mon-dd-yyyy "") col1, col2 'c', 3.05 col3 FROM dual
    UNION ALL
    SELECT to_date (January 14, 2014 ',' mon-dd-yyyy "") col1, col2 'b', 6.00 col3 FROM dual
    UNION ALL
    SELECT to_date (15 January 2014 ',' mon-dd-yyyy "") col1, col2 'b', 6,10 col3 FROM dual
    UNION ALL
    SELECT to_date (15 January 2014 ',' mon-dd-yyyy "") col1, col2 'c', 6.05 col3 FROM dual
    )
    a, as
    (
    SELECT
    col1
    col2
    col3
    count (col1) on count_col1 (col1 partition)

    Of
    t
    )

    Select
    a.Col1
    a.col2
    a.col3
    case when a.count_col1 = 1
    then a.col3
    Max (t.col3) else keep (dense_rank of the first order by t.col1 desc)


    end                                                                         new_col3

    Of
    one
    left join (t.col1 t<>

    Group
    a.Col1
    a.col2
    a.col3
    a.count_col1
     
    order by
    a.Col1

    ;

    COL1 COL2 COL3 NEW_COL3
    --------- ---- ---- --------
    1 January 14 a 1.04 1.04
    5 January 14 a 1.02 1.02
    January 8, 14 b 1.01 1.01
    January 10, 14 b 1.05 1.01
    January 10, 14 2 b 1.01
    10 January 14 c 3.05 1.01
    January 14, 14 b 6 of 6
    15 January 14 b 6.1 6
    15 January 14 c 6.05 6

    9 selected lines

    Kind regards

    Peter

  • Functions in the inner query

    Hello!
    I challenged the following problem. Here's the simple query:

    SELECT id, id, id from
    (select 1, sys_guid () as double id)

    as you can see there is a sys_guid() function in the inner query. So, why do we use these
    constructions? Right - to calculate the value of a function once and use it again so much
    time, that we need. So I guess to get three identical fields. But, as it turns out, it is not
    always too! I mean, on one version of Oracle database this query return the same three
    fields, but on another - three different! Based on what the sys_guid() function is a kind of
    random function, I can assume that the function is run three times in the second case
    instead of one (as it should)! So why is it? Is - this bug from version, or an option in
    control file that influence the optimizer?

    PS: I found a workaround on this basis, where this query produces abnormal results, we can use
    Internal ORDER BY clause in the query:

    SELECT id, id, id from
    (select 1, sys_guid () as command id double by 1)

    The oracle optimizer is the fusion view inline with the outer select block. He replaced effectively by:

    select sys_guid(), sys_guid(), sys_guid()
    from dual
    

    You can avoid this as follows:

    select /*+ no_merge(x) */
             id,id,id from
    (select 1,sys_guid() as id from dual) x
    

    Published by: Toon Koppelaars on July 9, 2009 09:22

  • Choice of the message can be changed in the table of search results Simple query region?

    Hi friends,

    I have a Simple search query region in 11i.

    I created the SearchVO and bound to the query Table Region.

    I have two attributes MessageStyleText and a MessageChoice attribute in the simple search criteria.

    Search results show very well for all attributes.

    But when I search with the criteria of MessageChoice, in the table of results, this attribute MessageChoice is indicated as editable, display the drop-down list.

    I did this attribute ReadOnly = True but then it becomes readonly in search also. So this dosent help.

    I need to this drop-down list of MessageChoice be modifiable in the search criteria, but read in the table of results.

    Please help me with the resolution. Its kinda urgent.

    Would appreciate any help.

    Thank you

    Rajesh

    He solved.

    Added programmatically in code.

    Kept the attribute as MessageChoice in the query Table Region.

    Added to the controller

    ' Public Sub processRequest (pageContext OAPageContext, OAWebBean webBean)

    {

    super.processRequest (pageContext, webBean);

    OAM OAApplicationModule = pageContext.getRootApplicationModule ();

    OAMessageChoiceBean = processFlagMessageChoice

    (OAMessageChoiceBean) webBean.findChildRecursive ("AttributeId");

    processFlagMessageChoice.setReadOnly (true);

    }

  • Decode the query help

    Hello
    I'm new to the development of Oracle.
    Oracle 10 g 2

    My original query:

    SELECT APP, count (*)
    TRANSACTION
    WHERE TYPE in ('ShipmentConfirmPR', 'ShipmentConfirm', 'ShipConfirm')
    and the APP ("SAPPI", "SAPPI", "SAPR3") and INTERVENE ('9320 ', '9332','1208 ')
    GROUP BY APP TYPE
    order of the APP

    the result of this query:
    SAPPI 100
    SAPPI 600
    SAPR3 440

    My requirement
    And I want to have something like output

    LDCS 100
    TSW 600
    PDC 440

    IE.the APPP and STEP combinations. Must return the specified values
    SAPPI & 9320-> LOC (here SAPPI IE APP is the same for both... but it's a coincidence IE APP can be sliced also)
    SAPPI & 9332-> tsw
    SAPR3 & 1208-> pdc

    Options, I tried:
    Query provided by one of the Forum members...
    SELECT THE CHECK BOX
    WHEN APP = "SAPP1" THEN DECODE (step, '9320', 'LSW', '9332', "TSW")
    WHEN APP = "SAPR3" step = '1208' AND 'PDC '.
    END app
    COUNT (*)
    TRANSACTION
    WHERE TYPE in ('ShipmentConfirmPR', 'ShipmentConfirm', 'ShipConfirm')
    AND THE APP ("SAPPI", "SAPPI", "SAPR3")
    AND STEP IN ('9320', '9332', ' 1208')
    GROUP BY APP, STEP
    ORDER OF THE APP.

    EXECUTION PLAN

    | ID | Operation | Name |
    ------------------------------------------------------------------------
    | 0 | SELECT STATEMENT |
    | 1. GROUP SORT BY |
    | 2. INLIST ITERATOR.
    | 3. TABLE ACCESS BY INDEX ROWID | TRANSACTION |
    | 4. INDEX RANGE SCAN | TRANSACTION_IDX |


    The output of the query (as above) must partially match the following query (a particular combination of CLO)

    SELECT count (1)
    TIBCO. TRANSACTION_HISTORY
    WHERE TYPE = 'ShipmentConfirm '.
    and APP in ("SAPPI") and INTERVENE ('9332')


    My Questions:

    1.*There are indexes on all 3 APP passes it's IE, STEP and TYPE *. I don't want a FULL table Scan (as one would use the index). Can change us the query / use of indices, etc. to make it faster?

    2. is the right to approach? Would the use of the concat operator in the function decode work better for my needs?
    Something like

    Select decode (APP |) STEP, 'SAPP9332', 'X') of TRANSACTION_HISTORY where < COND >

    If Yes can you please provide the query?

    3. ANY other approach / request for my requirement.

    Thanks in advance.

    Hello

    user13517642 wrote:
    ... EXECUTION PLAN

    | ID | Operation | Name |
    ------------------------------------------------------------------------
    | 0 | SELECT STATEMENT |
    | 1. GROUP SORT BY |
    | 2. INLIST ITERATOR.
    | 3. TABLE ACCESS BY INDEX ROWID | TRANSACTION |
    | 4. INDEX RANGE SCAN | TRANSACTION_IDX |

    The output of the query (as above) must partially match the following query (a particular combination of CLO)

    SELECT count (1)
    TIBCO. TRANSACTION_HISTORY
    WHERE TYPE = 'ShipmentConfirm '.
    and APP in ("SAPPI") and INTERVENE ('9332')

    My Questions:

    1.*There are indexes on all 3 APP passes it's IE, STEP and TYPE *. I don't want a FULL table Scan (as one would use the index). Can change us the query / use of indices, etc. to make it faster?

    A full table scan might be the fastest way to get results. Do you have any reason to think that it would be faster to go through the index? How selective are the clues? In other words, what is the percentage of rows in the table correspond to each of the values in the WHERE clause?

    2. is the right to approach?

    It depends on what you're trying to do, which is not at all clear to me.

    Would the use of the concat operator in the function decode work better for my needs?
    Something like

    Select decode (APP |) STEP, 'SAPP9332', 'X') of TRANSACTION_HISTORY where

    If you use this approach, look out for the problem Ab asse crevit . For example, if you have these 4 rows and 2 columns:

    str1     str2
    ----     ----
    (NULL)     FOO
    F     OO
    FO     O
    FOO     (NULL)
    

    There are 4 values of distict of str1 (counting NULL) and 4 separate values of str2, str1 but | str2 is the same for each of them. In the above example, it there is no way to know, just by looking at the concatenated string, including str1 and str2 ends begins. Maybe it's not the case for your specific data (for example, if the application is still exactly 5 characters long). otherwise, you may need to add some kind of delimiter, like this

    app || '+' || step
    

    where you know that '+' never occurs in one of these columns.

    3. ANY other approach / request for my requirement.

    CASES, as I mentioned in your previous message:
    Decode the help function
    and as you have used above.

    In this thread, you said "I have to use the decode function. Why? It is a competition of school Etudieeo DECODE is explicitly required? Why you don't want in the best way, what that turns out to be?

    Your WHERE clause:

    AND APP IN ('SAPPI', 'SAPPI', 'SAPR3')
    AND STEP IN ('9320', '9332', '1208')
    

    admits 6 possible combinations of APA and step:

    app     step
    -----     ----
    SAPP1     9320
    SAPP1     9332
    SAPP1     1208
    SAPP3     9320
    SAPP3     9332
    SAPP3     1208
    

    but you are looking for only 3 of these combinations in DECODE it or the expression BOX. (Have 2 copies of 'SAPP1' e list won't do any good, but it does hurt real, either.)
    By the way, is "SAPPI" app with the letter 'I' at the end, or "SAPP1", with the number '1' at the end?

    Published by: Frank Kulash, March 24, 2011 19:44

  • SQL query to dynamically filter the records-need help

    Hello

    I have a table with the structure as below

    Create table T1
    (Number (5) ID,)
    Action Varchar2 (20)
    )


    Here's the table of contents at different points in time and please help me with a query that must dynamically discover the results according to the entries in the table.

    First Table contents

    1 pending
    2 waiting


    Result of the query must be

    1 pending
    2 waiting


    After an insert the Table of contents

    1 pending
    2 waiting
    3 ignored

    Result

    Nothing should be displayed


    After an insert the Table of contents
    1 pending
    2 waiting
    3 ignored
    4 ignored

    Result
    Nothing should be displayed

    After an insert the Table of contents
    1 pending
    2 waiting
    3 ignored
    4 ignored
    5 in queue

    Result
    5 in queue

    Thanks in advance!

    Best regards
    Sridhar

    Hi, Sridhar,

    So you want to show t1 lines that come after the last row with action = "Ignored", which means no output at all during the last row has action = "ignored". (A line with a given id is considered as ' after' a line with a lower id. The line with the highest id is considered the "last" line.)
    Is this fair?

    Here's one way:

    SELECT     *
    FROM     t1
    WHERE     id  > (
              SELECT  MAX (id)
              FROM     t1
              WHERE     action     = 'Ignored'
               )
    ;
    

    It's not assume this id is whole consecutive.

    If the id is not unique, what results do you want? There is a chance that the above query is already doing if this is not the case, it can probably be changed.

  • Helps the GREP query

    Hello

    I'm struggling with a Grep style and need a little help.

    I write a manual containing many examples of code and you want to apply the color to the text inside "double quotes".

    Grep query ("? < =------="). + ? ("? =") is almost what I need but if it finds "" the query seems to stop to find anything afterwards.

    The------= in the look ahead is because the first "always follows a =

    For example:

    "" < page PREVIEWTEXT = "1" name ="previewtext1" column = "1" rowspan ="6"invite"" width = "250" height = "290" / > "

    After the prompt empty"", the search query is no longer "250" or "290".

    Anyone has any idea why?

    Thank you.

    And, in the case where you think that this is already a total mystery:

    I wondered what would happen with quotes. After all, the GREP search was to treat each of them even. Well - it does not work. The "\x{22" code} forces a straight quotation mark, so it will never match those curly. Fortunately, you can use a group for inclusion in the postanalyse:

    (? == [quote straight + curly quote open + curly close quote])

    (written in full so you can see what I've done.) But I accidentally stumbled upon this:

    (?<==["])[^"]+?(?=")
    

    ... it works for all possible combinations of straight open, curly and curly close quotes... Remove the [] in the postanalyse and it no longer works. Add them and it works again.

Maybe you are looking for