How to select rows whose column contains specific characters?

It is a telling of the T1 table with say column C1

Either the C1 field values:

1st row) OF/SPT/A/FWD
line 2) G/SPT/DE/OF/SPT
rank 3) R/FWD/SPT/A/FWD/FWD
rank 4) A/A/OF/SPT/FWD
rank 5) FWD/SPT/E/OF/A


How to get only the lines whose C1 column contains FWD last?

We can solve this problem with the simple use of a wildcard character:

    select *
    from t1
    where c1 like '%FWD'
    /

Note that this query runs a full table scan, because any index you can have on C1 will be ignored: the indexes are organized on the main characters.

Cheers, APC

Tags: Database

Similar Questions

  • How to Exchange rows and columns where to access the paper web in html IE

    Hi all!

    I use web analytics studio Oracle hyperion with Version: 11.1.1.2.0.940. Design of web document analysis, I use the spreadsheet, then turn to the analysis view, I can swap the row and column position by dragging and pulling.

    But when I access the document by the smartcut in ie browser, opening in the html template, how can I exchange line and column position?

    Thank you very much in advance.

    OK, I think I understand what you're saying. The problem is that it does not show the left pane with a smartcut.

    Here's a tip. Add a button of 'Service '. Add "Information Toggle Pane" as the service.

    When you click the button that will open the left handle in HTML view panel. You will then see row and column and you should be able to switch the dimensions as needed. I just tested and it works.

    hope that helps.

  • How to turn rows into columns

    Suppose I have the following table:

    FIELD1 FIELD2 FIELD3
    a desc1 5
    a 10 desc2
    desc1 b 3
    b desc3 6
    desc4 c 2
    ...

    I would like to write a query, get the following result in order not to get a dulpication for Field1:

    FIELD1 DESC1 DESC2 DESC3 DESCS4
    a 10 5
    3 6 b
    a p
    ...

    Can you help me?
    Thanks in advance

    Mark

    Hello
    This link can help you:
    http://saadnayef.blogspot.com/2010/05/converting-rows-to-columns-and-Vice.html

    Saad,

  • How effectively select rows randomly a large table?

    Hello

    The following code selects 5 lines of a random set of rows in the table emp (employee)
    select * 
      from (
           select ename, job
             from emp
           order by dbms_random.value()
            )
    where rownum <= 5
    My concern is that the internal selection causes a table scan in order to assign a random value to each line. This code when it is used against a large table can be a performance issue.

    Is there an effective way to random selection rows in a table without having to do a table scan? (I'm new to Oracle, so it is possible that miss me a very simple way to perform this task.)

    Thank you for your help,

    John.

    Published by: 440bx on July 10, 2010 18:18

    Take a look at the clause of the select statement. The number in brackets is a percentage of the table.

    SQL> create table t as select * from dba_objects;
    
    Table created.
    
    SQL> explain plan for select * from t sample (1);
    
    Explained.
    
    SQL> @xp
    
    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------
    Plan hash value: 2767392432
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |   725 | 70325 |   289   (1)| 00:00:04 |
    |   1 |  TABLE ACCESS SAMPLE| T    |   725 | 70325 |   289   (1)| 00:00:04 |
    ----------------------------------------------------------------------------
    
    8 rows selected.
    
  • SQL for sort a column containing digital/characters/alphanumeric characters.

    I have a table with the column can contain numbers, characters, and a combination of numbers and characters. Here is an example of the table. In this regard, I would like to sort the table in the following way.

    (a) sort first numbers in numerical order and then would sort the others in the order of the characters.

    Example: -.

    RUN SQL
    SQL > select * from temp;

    ID
    ---------------
    A
    22
    46
    CC
    BBB
    46jkb
    1
    10
    100
    one

    AFTER CORRECTION
    SQL > < MAGIC SQL statement >

    ID
    ---------------
    1
    10
    22
    46
    46jkb
    100
    one
    A
    BBB
    CC

    I tried asciistr, to_char and to_number and many other combinations. However, no luck :-(. Any help will be much appreciated.

    SQL statement - to create and insert data in the table-
    create table temp (id varchar2 (15));
    insert into temporary values ('A');
    insert into temporary values ('22');
    insert into temporary values ('46');
    insert into temporary values ("CC");
    insert into temporary values ("BBB");
    insert into temporary values ('46jkb');
    insert into temporary values ('1');
    insert into temporary values ('10');
    insert into temporary values ('100');
    insert into temporary values ('a');
    commit;
    with t as (
               select 'A' str from dual union all
               select '22' str from dual union all
               select '46' str from dual union all
               select 'CC' str from dual union all
               select 'BBB' str from dual union all
               select '46jkb' str from dual union all
               select '1' str from dual union all
               select '10' str from dual union all
               select '100' str from dual union all
               select 'a' str from dual
              )
    select  str
      from  t
      order by lpad(regexp_substr(str,'^\d+'),max(length(regexp_substr(str,'^\d+'))) over(),'0') || upper(regexp_replace(str,'^\d+'))
    /
    
    STR
    -----
    1
    10
    22
    46
    46jkb
    100
    A
    a
    BBB
    CC
    
    10 rows selected.
    
    SQL> 
    

    SY.

  • How to select rows randomly by the percentage of lines by specific column

    I need to select exactly 20% of lines by Department randomly. Ex, table composed of 50 records for the Sales Department, 60 discs for the Department of human resources. I need to get 10 records of the Department sales and 12 records of Department of human resources. but records should be chosen at random. How to get out of it? Thanks in advance.

    Select

    DEPTNO

    count (*) NTC

    WCP

    Deptno group

    DEPTNO CNT

    30 6

    20 5

    3 of 10

    Choose 50% in every department at random

    expected (round up to the next integer)

    DEPTNO CNT

    30 3

    20 3

    2 of 10

    Select * from)

    Select

    EmpNo

    deptno

    , count (*) during the (partition deptno) cnt

    row_number() over (partition by deptno arrested by dbms_random.random) rn

    WCP

    )

    where rn<=>

    order by deptno

    EMPNO DEPTNO CNT RN

    7782 10 3 1

    7934 10 3 2

    7566 20 5 1

    7876 20 5 2

    7902 20 5 3

    7900 30 6 1

    7521 30 6 2

    7654 30 6 3

  • Select-&gt; how to convert rows to columns

    Hi, I need your help please.

    I have three options: A, B, C in table T_OPTIONS (no more, no less, it's always 3)

    No I can assign items to this option.
    Section 1, 2, 3, 4

    in the table, it looks like this

    ARTICLE_ID T_OPTIONS

    1                   A
    1                   B
    2                   C
    3                    A
    3                    C

    But now I want to have a select statement that transform the lines in columns, it should look like this

    A, B AND C OF ARTICLE
    1             x x
    2             x
    3             x   x


    Can you help me!?

    Published by: Dila on 02.08.2012 01:52

    Published by: Dila on 02.08.2012 01:53
    SQL> with t as (
      2  select 1 article_id, 'A' options from dual union
      3  select 1,'B' from dual union
      4  select 2,'C' from dual union
      5  select 3,'A' from dual union
      6  select 3,'C' from dual
      7  )
      8  --
      9  --
     10  --
     11  select article_id article
     12  ,      max(case when options = 'A' then 'x' end) A
     13  ,      max(case when options = 'B' then 'x' end) B
     14  ,      max(case when options = 'C' then 'x' end) C
     15  from   t
     16  group by article_id
     17  order by article_id;
    
       ARTICLE A B C
    ---------- - - -
             1 x x
             2     x
             3 x   x
    
    3 rows selected.
    
  • How to select rows as some passes?

    Hi all

    11.2.0.1

    I have two tables

    Emp1 (name1) contain values:

    =================

    Justin bieber peralta

    Bruno March minoza

    EMP2 (name2) contain values:

    =============

    Bieber

    March

    I want to choose emp1 name1 where name1 like ' % | name2. %' of emp2.

    I'm confused about the syntax

    Thank you

    pK

    Select e1.*

    from emp1 e1

    emp2 e2

    where e1.name1 like '% "| E2.name2 | '%'

    Ery Plan

    Operation Options Object Rows Time Cost Bytes Filter
    Predicates *
    access
    Predicates
    SELECT STATEMENT

    31 015 1 796 527 255

    NESTED LOOPS

    31 015 1 796 527 255

    ACCESS TABLE

    STORAGE FULL EMP2 8 1 4 40

    ACCESS TABLE

    STORAGE FULL EMP1 3 877 1 99 46 524 'E1 '. "' NAME1 ' LIKE '%" | ' ' E2 '. "' NAME2 ' | " %' 'E1 '. "' NAME1 ' LIKE '%" | ' ' E2 '. "' NAME2 ' | " %'

    Columns not indexed are marked in red

    Columns in index

    Not found index

    Columns in the table

    Table Owner Table Name Column Name Data Type
    ETBIN EMP1 NAME1 VARCHAR2
    EMP2 NAME2 VARCHAR2

    Select *.

    from emp1

    where exists (select 1 from emp2 where emp1.name1 like '%' | name2 |) '%')

    Query plan

    Operation Options Object Rows Time Cost Bytes Filter
    Predicates *
    Access
    Predicates
    SELECT STATEMENT

    32 13 9 850 384

    FILTER

    THERE ARE (SELECT "EMP2" 0 'EMP2' WHERE: B1 LIKE '%' |) "' NAME2 ' | " %')

    ACCESS TABLE

    STORAGE FULL EMP1 77 537 1 101 930 444

    ACCESS TABLE

    STORAGE FULL RANKS FIRST EMP2 1 1 4 5 : B1 LIKE "%" | "' NAME2 ' | " %'

    Columns not indexed are marked in red

    bars

    Not found index

    Columns in the table

    Table Owner Table Name Column Name Data Type
    ETBIN EMP1 NAME1 VARCHAR2
    EMP2 NAME2 VARCHAR2

    Select *.

    from emp1

    where to trim (substr (name1,

    InStr (name1,' ', 1, 1) + 1.

    InStr (name1,' ', 1, 1)-instr (name1,' ', 1, 1)

    )

    ) in select (separate name2

    from emp2

    )

    Query plan

    Query plan

    Operation Options Object Rows Time Cost Bytes Filter
    Predicates *
    Access
    Predicates
    SELECT STATEMENT

    77 537 1 109 1 318 129

    HASH JOIN

    77 537 1 109 1 318 129 'NAME2' = TRIM (SUBSTR ('NAME1', INSTR ("NAME1",' ', 1, 1) + 1, INSTR ('NAME1',' ',(-1), 1)-INSTR ("NAME1", "", 1.1)))

    VIEW

    VW_NSO_1 2 1 5 10

    HASH

    UNIQUE 2 1 5 10

    ACCESS TABLE

    STORAGE FULL EMP2 8 1 4 40

    ACCESS TABLE

    STORAGE FULL EMP1 77 537 1 101 930 444

    Columns not indexed are marked in red

    Ndex columns

    Not found index

    Columns in the table

    Table Owner Table Name Column Name Data Type
    ETBIN EMP1 NAME1 VARCHAR2
    EMP2 NAME2 VARCHAR2

    According to very different plans, it must be a difference any.

    (ascheffer posted before cardinalities were known)

    Concerning

    Etbin

  • Divide a row in columns on specific character

    Hello

    I have a table where a data column must be spllitted on, every time a character specific carats found.

    Any help would be appreciated.

    Table_Sample

    Col1 Col2

    ASD 123 ^ pqwer ^.

    23 a ^ b ^ c

    expected results

    Col1 Col2

    ASD 123

    pqwer 123

    23 a

    23 b

    23 c


    Hello

    Here's one way:

    SELECT col1

    REGEXP_SUBSTR (col2,

    , '[^^]+'

    1

    LEVEL

    ) AS col2_sub

    OF table_sample

    CONNECT BY LEVEL<= regexp_count="" (col2,="">

    AND PRIOR col1 = col1

    AND PRIOR SYS_GUID () IS NOT NULL

    ;

    As always, the solution depends on your data, your needs and your version of Oracle.

  • SQLLDR: How to fill the empty columns with specific data by default?

    Hello

    We are 11G

    Here is a complete example:

    (1) the definition of the table:
    create table IMPORT_PRJ_TIMESHEETS
    (
      RESSOURCE_CODE VARCHAR2(20),
      REFERENCE_DATE VARCHAR2(20),
      STATUS         VARCHAR2(20),
      PROJET_CODE    VARCHAR2(50),
      TACHE_ID       VARCHAR2(100),
      TACHE_DESC     VARCHAR2(250),
      RAF            NUMBER,
      JOUR1          NUMBER,
      JOUR2          NUMBER,
      JOUR3          NUMBER,
      JOUR4          NUMBER,
      JOUR5          NUMBER,
      JOUR6          NUMBER,
      JOUR7          NUMBER,
      IMPORT_DATE    DATE
    );
    (2) the CTL:
    LOAD DATA
    CHARACTERSET WE8ISO8859P1
       APPEND INTO TABLE IMPORT_PRJ_TIMESHEETS
    -- Pour eliminer la ligne d'en-tete
    WHEN PROJET_CODE != 'ID projet'
       FIELDS TERMINATED BY '*-*' OPTIONALLY ENCLOSED BY '"'
    ( RESSOURCE_CODE       CONSTANT '!RESSOURCE_CODE!'
    , REFERENCE_DATE       CONSTANT '!REFERENCE_DATE!'
    , STATUS               CONSTANT '!STATUS!'
    , PROJET_CODE          CHAR
    , TACHE_ID             CHAR
    , TACHE_DESC           CHAR
    , RAF                  CHAR "TO_NUMBER( :RAF, '999G999D99')"
    , JOUR1                CHAR
    , JOUR2                CHAR
    , JOUR3                CHAR
    , JOUR4                CHAR
    , JOUR5                CHAR
    , JOUR6                CHAR
    , JOUR7                CHAR
    , IMPORT_DATE          SYSDATE
    )
    {code}
    
    
    3) the datafile :
    {code}
    ID projet*-*ID tâche*-*Tâche/Description*-*RàF*-*lun. 13/07*-*mar. 14/07*-*mer. 15/07*-*jeu. 16/07*-*ven. 17/07*-*sam. 18/07*-*dim. 19/07*-*
    FR-FR-NT2300135*-* *-*GAMMAWEB - Coordination*-*0,00*-* *-* *-* *-*8,00*-*8,00*-* *-* *-*
     *-* *-*Holiday*-* *-* *-*8,00*-* *-* *-* *-* *-* *-*
     *-* *-*Special leave*-* *-*8,00*-* *-* *-* *-* *-* *-* *-*
     *-* *-*Vacation*-* *-* *-* *-*8,00*-* *-* *-* *-* *-*
    
    {code}
    
    - As you can see, the datafile delimiter is "*-*" .... there's no pb about this.
    
    - Also, there are 5 lines in the datafile. Currently, the _*load status*_ is :
       - Line 1 is the header  >>> not loaded, and that's fine with me.
       - Line 2 is successfully loaded
       - Line 3 / Line 4 / Line 5 : are not loaded .. but I need these lines ...
    
    *What I'd like to get is to successfully load lines 3 to 5 with a default values for the first 3 columns (project/task ID/ task desc)*
    
    I hope it's clear enough and that you will be able to provide a good answer ..
    
    Thanks in advance,
      Olivier                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    In your example, the only ranked with value on all lines is TACHE_DESC.
    If this field is always filled, try this:
    WHEN TACHE_DESC! = "Task/Description".

    Concerning

  • How can I insert a number to a specific index (row and column) to a table

    I had the most with function 'insert into array' problem because of its counter-intuitiveness. I want to insert a number I got inside a loop IN a table. The ROW and COLUMN of this table I want enter the number is specified by the number of loops of two loops FOR. It did not work.

    So, I have isolated and tested this function further. Frankly, I initialized a table 2D with ZEROS and plugged into the "insert into array" function (on top of entry). I then put the number '1' for the index (line) and the number "2" for the index (column) and then put the entry number "6" for the "new item/sub-table. Then, I hung a picture of 2-D (indicator) output to the output of the function "insert into array. When I did all that, it means I want to just put the number '6' in line '1' and the column '2'... This isn't letting me do it.

    How can I do this SIMPLE?

    Hi Darrell h...,

    Looks like you can use the function "autoindexing. Take your value and connect it to your loop, it will be a default autoindexing. Right-click on the last tunnel of output and select Create indicator, the result is your table.

    It will be useful.

    Mike

  • Selection of rows where column string contains special characters.

    Hey there,

    Im trying to select rows based on a column containing a bar slash.

    I tried

    where substr (col1, INSTR(col1,'/'), INSTR(col1,'/') + 1)

    but no luck, is there a special way to treat this?

    Thanks in advance,
    Date of birth
    instr (str, '/') > 0
    

    as in

    SQL> with test
      2  as
      3  (select 'this first string contains / a slash' str from dual union all
      4   select 'this second string contains / a slash' str from dual union all
      5   select 'this third does not' str from dual
      6  )
      7  select *
      8    from test
      9   where instr (str, '/') > 0
     10  /
    
    STR
    -------------------------------------
    this first string contains / a slash
    this second string contains / a slash
    
  • How to find DB tables containing specific columns (ORG_ID / ORGANIZATION_ID)

    Hi all, I would like to know if someone has developed a script to find all tables containing the columns (fields) specific.


    I'm on a migration project where I don't have access to the source of the DB, I just ask for queries and I to reflect all the tables DB containing specific data of organization.

    So the first step was to understand used tables and I get them, now I understand what tables have Org_id / Organization_ID and fields of the SOURCE of the LANGUAGE/LANGUAGE (source DB has much set Org and many languages also, so I need to filter the 100total 6ORG_ID and 2 languages of 8 total installed)

    Can anyone help?

    Thank you

    Best regards

    Pietro

    Hello

    You can see this:

    Find all tables in db with the name of the column of a particular string?

    Kind regards

    MihaiF

  • How to update a table whose name column contains an ampersand?

    Hello

    I need to update a column whose column name contains an ampersand and cannot find a way to do it. Option is not there to have the name of the column changed.

    Ex:

    Aircraft UPDATE
    SET d & f = 1
    WHERE aircraft_code = '737';

    This property returns an error of missing an = sign

    I tried:
    TOGETHER would be ' |' &' | 'f' = 1

    does not work


    Any help is greatly appreciated.

    Thank you
    Laura

    SET DEFINE OFF
    stop to interpret the & sign as from a lexical setting on the client.

    Not sure if you have this problem here.
    & could also has power not characters in the normal column names (didn't test).

    In this case, you will need to put the name of column ".»

    + example +.
    {code}
    Aircraft UPDATE
    The VALUE "d & f" = 1
    WHERE aircraft_code = '737';
    {code}

    Be aware that in this case the column name must be spelled exactly as if it was when the table was created.
    Included case.

    {code}
    Aircraft UPDATE
    THE "D & F" VALUE = 1
    WHERE aircraft_code = '737';
    {code}

  • How to get the string (specified by row and column) of txt file with labview

    Hello world

    How to get the string (specified by row and column) of txt file with labview

    THX

    As far as I know, a text file has no column.  Be more specific.  Do you mean something like the 5th word on line 4, where the words are separated by a space, and lines are separated by a newline character?  You can read from the spreadsheet String function and set the delimiter to a space.  This will produce a 2D channels table.  Then use the table to index and give the line number and column number.

Maybe you are looking for