Query for selecting first  3 characters of name of any person

query for selecting first 3 characters of name of any person

10:52:44 SQL> SELECT SUBSTR(ename, 1, 3) first_three FROM emp;
FIRST_THREE
SMI
ALL
WAR
JON
MAR
BLA
CLA
SCO
KIN
TUR
ADA
FIRST_THREE
JAM
FOR
MIL
Ton
15 rows selected.
Elapsed: 00:00:00.00

Similar Messages

  • Error while executing a sql query for select

    HI All,
    ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.

    I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
    1. I dont want to increase the temp space
    2. I need to tune the query, please provide your recomendations.
    insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
    (REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
    select
    REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
    carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
    carrier_item_type,carried_item_protection_type,'PACS'
    from
    (select distinct
    c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
    a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
    a.carrier_item_type,a.carried_item_protection_type,'PACS'
    from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
    where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
    AND a.carrier_items=b.mux
    and c.REPORTNUMBER=(case
    when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
    else 20
    end)
    and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
    where not exists
    (select *
    from CST_DSA.HIERARCHY_MISMATCHES B where
    A.REPORTNUMBER=B.REPORT_NUM and
    A.REPORTTYPE=B.REPORT_TYPE and
    A.REPORTDESCRIPTION=B.REPORT_DESC and
    A.CARRIED_ITEMS=B.CARRIED_ITEMS and
    A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
    A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
    A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
    A.CARRIER_ITEMS=B.CARRIER_ITEMS and
    A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
    A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
    AND B.SOURCE_SYSTEM='PACS'
    Explain Plan
    ==========
    Plan
    INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1                                                        
         20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES                                                   
              19 PX COORDINATOR                                              
                   18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                         
                        17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                    
                             15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1                               
                                  4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621                          
                                       3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                     
                                            2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                
                                                 1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621           
                                  14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448                          
                                       11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448                     
                                            8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002               
                                                 7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2           
                                                      6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2      
                                                           5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
                                            10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448                
                                                 9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448           
                                       13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1                     
                                            12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1                
                             16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1

  • Query for selecting the 4 highest marks of the student

    query for selecting the 4 highest marks of the student

    Guys dont start an argument,
    tey this one; please
    Hi,
    Try this
    Top 4
    Select ename,
    sale
    From dept d,
    emp e1
    Where d.deptno = e1.deptno
    And &p > (Select Count(e2.sal)
    From emp e2
    Where e2.sal > e1.sal
    And e2.deptno = e1.deptno
    Order By 1,2
    Bottom 4
    Select ename,
    sale
    From dept d,
    emp e1
    Where d.deptno = e1.deptno
    And &p > (Select Count(e2.sal)
    From emp e2
    Where e2.sal < e1.sal
    And e2.deptno = e1.deptno
    Order By 1, 2
    &P you use any value say 3,4,5,6
    This is top N analysis
    Regards
    Umesh

  • Query for select CLOB data field

    Hi All,
    I want to know how to write a SQL query for select CLOB tyoe data from a tablw. when I am trying to use the simple SQL it gives an messageLOB types requires OCI8 mode and currently uasing OCI7 ode.
    Also I am not aware of oci mode?
    If its working for OCI8 mode how I should changer it in to OCI8 mode? (I am using 10g rel 2)
    Thans and regards
    Buddhike

    Hi ,
    i don't want to use loop (sy-tabix) ..
    any particular reason for this ?
    as u cannot automatically generate serial number, u have to go for loop....endloop.
    Thanks
    Karthik

  • Selecting first N characters when querying the CMS

    I am trying to retrieve only the first 6 characters of the SI_KEYWORDS field when querying the CMS from within the SDK.  When testing within QueryBuilder the following in bold does not work, although LEFT is a command for achieving this in SQL.  Can someone help me to know if this is possible within QueryBuilder SQL and if so how to achieve it?
    Select LEFT(SI_KEYWORD,6) as keyword, SI_NAME From CI_INFOOBJECTS, CI_SYSTEMOBJECTS, CI_APPOBJECTS WHere SI_KIND='webi'
    and SI_KEYWORD != '' and SI_KEYWORD != 'Hidden' and SI_KEYWORD != 'Auditor'
    ORDER BY keyword, SI_NAME
    Thanks,
    Dave

    Hi Ted,
    Thanks for your reply.  I understand the querying of the CMS better after reading it. 
    We are utilizing the keywords field and the description field to obtain some metadata about our reports that I need to access from java code.  Unfortunately, we have 4 different pieces of metadata we want to store and only the 2 fields in which to store them, so we are using delimiters in the keywords field to separate the values.  For example, we have "value1value2" as the keyword field in one report, but in another report if value2 is blank we simply have "value1".  This works well as we just parse the delimiters in java and we can store the 2 different values in the one keyword field.  The part that is not working well with this approach, though, is ordering the results.  We want to order the reports by value1 and then by SI_NAME.  Because some of the reports have value1value2 and others just have value1 it throws this ordering off if I use "ORDER BY SI_KEYWORD, SI_NAME". 
    I've been looking for ways to get around this without doing a re-sort in Java and this is all I could think of:
    1. Are there some additional user-defined fields that we could expose in the report properties in the CMC, and then retrieve via Query Builder / SDK?  Something like SI_UDF1, SI_UDF2, etc.  All we could find were keywords and description.
    2. Using a SUBSTR or LEFT-like function on the keywords field so that it only gets value1 for sorting purposes only, but still retrieve the entire keywords field in the SELECT.  I understand now based on your explanation that this will not work as (if I understand correctly) it would modify the report object in the CMS to set the keyword to the truncated value.
    Any advice you could offer would be greatly appreciated.  I know I can always bite the bullet and do the sorting java-side once I get the resultset back, but I was hoping to avoid the performance hit of doing that.
    Thanks,
    Dave

  • Oracle SQL query for getting specific special characters from a table

    Hi all,
    This is my table
    Table Name- Table1
    S.no    Name
    1          aaaaaaaa
    2          a1234sgjghb
    3          a@3$%jkhkjn
    4          abcd-dfghjik
    5          bbvxzckvbzxcv&^%#
    6          ashgweqfg/gfjwgefj////
    7          sdsaf$([]:'
    8          <-fdsjgbdfsg
    9           dfgfdgfd"uodf
    10         aaaa  bbbbz#$
    11         cccc dddd-/mnm
    The output has to be
    S.no    Name
    3          a@3$%jkhkjn
    5          bbvxzckvbzxcv&^%#
    7          sdsaf$([]:'
    8          <-fdsjgbdfsg
    10         aaaa  bbbbz#$
    It has to return "Name" column which is having special characters,whereas some special chars like -, / ," and space are acceptable.
    The Oracle query has to print columns having special characters excluding -,/," and space
    Can anyone help me to get a SQL query for the above.
    Thanks in advance.

    You can achieve it in multiple ways. Here are few.
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'aaaaaaaa' name from dual union all
      5  select 2 id, 'a1234sgjghb' name from dual union all
      6  select 3 id, 'a@3$%jkhkjn' name from dual union all
      7  select 4 id, 'abcd-dfghjik' name from dual union all
      8  select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
      9  select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
    10  select 7 id, 'sdsaf$([]:''' name from dual union all
    11  select 8 id, '<-fdsjgbdfsg' name from dual union all
    12  select 9 id, 'dfgfdgfd"uodf' name from dual union all
    13  select 10 id, 'aaaa  bbbbz#$' name from dual union all
    14  select 11 id, 'cccc dddd-/mnm' name from dual
    15  )
    16  select *
    17    from t
    18   where regexp_like(translate(name,'a-/" ','a'), '[^[:alnum:]]');
            ID NAME
             3 a@3$%jkhkjn
             5 bbvxzckvbzxcv&^%#
             7 sdsaf$([]:'
             8 <-fdsjgbdfsg
            10 aaaa  bbbbz#$
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'aaaaaaaa' name from dual union all
      5  select 2 id, 'a1234sgjghb' name from dual union all
      6  select 3 id, 'a@3$%jkhkjn' name from dual union all
      7  select 4 id, 'abcd-dfghjik' name from dual union all
      8  select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
      9  select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
    10  select 7 id, 'sdsaf$([]:''' name from dual union all
    11  select 8 id, '<-fdsjgbdfsg' name from dual union all
    12  select 9 id, 'dfgfdgfd"uodf' name from dual union all
    13  select 10 id, 'aaaa  bbbbz#$' name from dual union all
    14  select 11 id, 'cccc dddd-/mnm' name from dual
    15  )
    16  select *
    17    from t
    18   where translate
    19         (
    20            lower(translate(name,'a-/" ','a'))
    21          , '.0123456789abcdefghijklmnopqrstuvwxyz'
    22          , '.'
    23         ) is not null;
            ID NAME
             3 a@3$%jkhkjn
             5 bbvxzckvbzxcv&^%#
             7 sdsaf$([]:'
             8 <-fdsjgbdfsg
            10 aaaa  bbbbz#$
    SQL>

  • A test query for selecting by ticketid

    This is a test query to select tickets by ticketid , starting with the most recent, as to get the top5 most recent tickets. There will be still mistakes in it. please don't tell me those about stupid mistakes,and spaces, at first and obvious syntax mistakes. Otherwise I don't learn it. My question has to do with the loop. Do you think it is useful to use a loop for this, or should it stay as it is, or should it be something else.
    DECLARE
    Define, and open a cursor;
    min_ticket NUMBER; -- minimum ticketid
    laatste_ticket NUMBER; -- latest ticketid
    tussen_ticket NUMBER; -- in between ticket
    Query_to_use VARCHAR2(4000);
    BEGIN
    Select max(ticketid) into laatste_ticketid from ticket;
    Select count(*) into teller from ticket where (ticketid<laatste_ticketid ) AND (ticketid>(laatste_ticketid-6));
    Select ticketid, categoriecd, titel into cursor from ticket where (ticketid<laatste_ticketid ) AND (ticketid>(laatste_ticketid-6));
    Select min(ticketid) into min_ticketid from ticket;
    If teller= < 5
         If teller = 5
              Query_to_use := Query_to_use || ';';
              Return Query_to_use;
         else
              --Loop through records from laatste_ticketid to min_ticketid
                   Select gebruikerid into te_testen_veld from ticket where ticketid = tussen_ticketid ;
                   If te_testen_veld is NULL THEN
                        tussen_ticketid := tussen_ticketid - 1;
                        te_testen_veld := NULL;
                   Else
    Query_to_use := query_to_use || ' UNION select ticketid, categoriecd, titel from ticket '||
                   ' where ticketid = tussen_ticketid ';
                   te_testen_veld := NULL;
                   Teller := teller + 1;
                        If (teller < 5)
                             tussen_ticketid := tussen_ticketid - 1;
                        Else if (teller = 5)
                             teller := 6;
                        End if;
                   End if;
              --End Loop;
         End if;
    End if;
    Query_to_use := Query_to_use || ';';
    Return Query_to_use;
    END;

    You can get all this using one SQL statement, without resorting to explicit cursors. Have a look at http://asktom.oracle.com and search for Top-N Query.
    Depending on what you are doing, you may want to use a cursor for loop.
    I assume this is for some sort of electronic queueing system. if you gave us more detail as to what you are trying to do, you may get better advice.

  • Issue in FF v 3.6.10: I have a page which have more than 20 link, clicking on these link opens up a popup using window.showModalDialog, for the first 20 popup opens up without any prob but for the 21st n more click it block the popup and do not open.

    Issue in FF v 3.6.10: I have a web page which have more than 20 link, clicking on each of these link opens up a pop-up using window.showModalDialog, for the first consecutive 20 popup opens up without any prob but for the 21st n more click it block the popup and do not open. This is m problem, the real user on the web page can click on more than 20 link in such a scenario it may create problem, please help

    Your above posted system details show outdated plugin(s) with known security and stability risks.
    *Shockwave Flash 9.0 r999
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://www.adobe.com/software/flash/about/
    In Firefox 3.6 and later versions you need the Next-Generation Java™ Plug-In present in Java 6 U10 and later (Linux: libnpjp2.so; Windows: npjp2.dll).
    http://java.com/en/download/faq/firefox_newplugin.xml
    See also http://java.sun.com/javase/6/webnotes/install/jre/manual-plugin-install-linux.html

  • SQL Query to get first four characters of an address

    Hi Gurus,
    Can you please help me with the below quries on how to achieve this. Could be really helpful if you could provide a sample sql from your side.
    Req:
    I have a requriement where I should display the first four non-space characters of an address eg: ROOM becomes R, FLAT becomes F etc. Passing in an address of ROOM A FLAT 1 STARFORD AVENUE would therefore result  ‘RAF1’, whereas an address of 23 CORNER STREET would become ‘23CO’.
    Words like c/o, co, rear of should be ignored if any.
    Thanks in Advance.
    Regards,
    Aash

    Hi, Ashwanth,
    Sorry, I don't have the time to do everything for you.
    Here's an example of a package body that does standardization.  If you can't use this exactly as it is, then at least it will give you some ideas:
    CREATE OR REPLACE PACKAGE BODY pk_stnd
    AS
    --  pk_stnd provides functions useful for standardizing names.
    -- **  s t a n d a r d i z e  **
    --  Return standardized spelling of given text.
    FUNCTION standardize
        in_text        IN VARCHAR2,
        in_grp_name    IN VARCHAR2,
        in_option_text IN VARCHAR2 DEFAULT ''
    RETURN VARCHAR2
    IS
    CURSOR pair_csr (target_grp_name VARCHAR2)
    IS
      SELECT
       st.bad_text,
       st.good_text
      FROM
       stnd_text st,
       stnd_text_grp stg
      WHERE
       stg.grp_name  = target_grp_name AND
       stg.stnd_text_id = st.stnd_text_id
      ORDER BY
       stg.order_val;
    max_len_val INTEGER := 4000;  -- Longest string to be returned
    rtn_text VARCHAR2 (4000);  -- Standardized text to return
    BEGIN
        rtn_text := UPPER (SUBSTR (' ' || in_text || ' ', 1, max_len_val));
        rtn_text := REPLACE (rtn_text, ',', ', ');
         FOR  pair_rec  IN  pair_csr (in_grp_name)
         LOOP
             rtn_text := REPLACE
                           rtn_text,
                           ' ' || pair_rec.bad_text  || ' ',
                           ' ' || pair_rec.good_text || ' '
        END LOOP;
        rtn_text := TRIM (rtn_text);
        RETURN rtn_text;
    END standardize;
    END pk_stnd;
    SHOW ERRORS
    This uses a table called stnd_text, that looks like this:
    CREATE TABLE stnd_text
    stnd_text_id NUMBER (6) PRIMARY KEY,
    bad_text VARCHAR2 (100) NOT NULL,
    good_text VARCHAR2 (100),
    cmnt_text VARCHAR2 (100)
    COMMENT ON TABLE stnd_text IS
    'Non-standard texts and their standard replacements';
    COMMENT ON COLUMN stnd_text.stnd_text_id IS
    'Arbitrary ID for primary key';
    COMMENT ON COLUMN stnd_text.bad_text IS
    'Non-standard text to be replaced';
    COMMENT ON COLUMN stnd_text.good_text IS
    'Standard text to replace non-standard (may be NULL if bad_text is to be deleted)';
    COMMENT ON COLUMN stnd_text.cmnt_text IS
    'Ad-hoc remarks on this entry';
    You may not want to use the other table, but if you do:
    CREATE TABLE stnd_text_grp
    stnd_text_grp_id NUMBER (6) PRIMARY KEY,
    stnd_text_id NUMBER (6),
    grp_name VARCHAR2 (50)  NOT NULL,
    order_val NUMBER   NOT NULL,
    cmnt_text VARCHAR2 (100)
    If you have problems writing your own function, post your best attempt, along with CREATE TABLE and INSERT statements for any tables needed, code that shows how you're calling the function, and a specific question.

  • Dynamic Query for 'Select IN' -- URGENT!!!

    I've got the following Select statement -
    SELECT Employee_Name, SSN FROM Company
    WHERE EMPLOYEE_NAME IN (c_Employee_Name) ;
    Here c_Employee_Name is a Returned RefCursor from another function. It gives error as Type mismatch.
    Is there anyway I can run one SELECT statement for all the Employee_Name returned by the function?
    Any sample code will be great.
    Thanks a lot,
    Suman

    If you have a packaged function that returns a ref cursor,
    something like this:
    CREATE OR REPLACE PACKAGE package_name
    AS
      TYPE c_employee_name IS  REF cursor;
      FUNCTION function_name
        (p_tables      IN  VARCHAR2,
         p_columns     IN  VARCHAR2 DEFAULT '*',
         p_where       IN  VARCHAR2 DEFAULT ' 1 = 1 ',
         p_others      IN  VARCHAR2 DEFAULT NULL)
        RETURN package_name.c_employee_name;
    END package_name;
    CREATE OR REPLACE PACKAGE BODY package_name
    AS
      FUNCTION function_name
        (p_tables      IN  VARCHAR2,
         p_columns     IN  VARCHAR2 DEFAULT '*',
         p_where       IN  VARCHAR2 DEFAULT ' 1 = 1 ',
         p_others      IN  VARCHAR2 DEFAULT NULL)
        RETURN package_name.c_employee_name
      IS
        v_sql              VARCHAR2 (4000) := NULL;
        v_results          package_name.c_employee_name;
      BEGIN
        v_sql :=
           ' SELECT ' || p_columns
        || ' FROM '   || p_tables
        || ' WHERE '  || p_where || ' '
        || p_others;
        OPEN v_results FOR v_sql;   
        RETURN v_results;
      END function_name;
    END package_name;
    Then, you can use a procedure, something like the
    one below, to call the function and loop through
    the ref cursor to concatenate a string of employee
    names to be used in the select statement.  You can
    then open another ref cursor for that select statment
    and process the results however you like.  I used
    dbms_output in the following example:
    CREATE OR REPLACE PROCEDURE procedure_name
    AS
      c_employee_names  package_name.c_employee_name;
      v_employee_name   company.employee_name%TYPE;
      v_employee_names  VARCHAR2 (4000) := NULL;
      v_delimiter       VARCHAR2 (1) := NULL;
      v_sql             VARCHAR2 (4000) := NULL;
      TYPE cursor_type IS REF CURSOR;
      cursor_name cursor_type;
      v_ssn             company.ssn%TYPE;
    BEGIN
      c_employee_names := package_name.function_name
                            ('company', 'employee_name');
      LOOP
        EXIT WHEN c_employee_names%NOTFOUND;
        FETCH c_employee_names INTO v_employee_name;
        v_employee_names := v_employee_names
        || v_delimiter
        || v_employee_name;
        v_delimiter := ',';
      END LOOP;
      v_employee_names := REPLACE (v_employee_names, ',', ''',''');
      v_sql := ' SELECT employee_name, ssn'
            || ' FROM   company'
            || ' WHERE  employee_name IN ('''
            || v_employee_names
            || ''')';
      OPEN cursor_name FOR v_sql;
      LOOP
        EXIT WHEN cursor_name%NOTFOUND;
        FETCH cursor_name INTO v_employee_name, v_ssn;
        DBMS_OUTPUT.PUT_LINE (v_employee_name || ' ' || v_ssn);
      END LOOP;
      CLOSE cursor_name;
    END procedure_name;
    To execute the procedure that calls the function:
    SET SERVEROUTPUT ON
    EXEC procedure_name

  • Query for selecting distinct by date

    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    I have a simple table that has an ID, Title, and Date.
    I need to select the most recent ID (without duplicates). I was looking at using a UNION but couldn't quite get it to work.
    P3XGL2FV96     Test 1     11-AUG-10 03.38.06.000000000 PM
    1VGJ74PSNW     Test 2     11-AUG-10 04.02.22.000000000 PM
    1VGJ74PSNW     Test 2     12-AUG-10 09.49.09.000000000 AM

    Hi,
    You could achieve it like this :
    CREATE TABLE MY_TABLE
    +(+
    ID       VARCHAR2(10),
    TITLE    VARCHAR2(10),
    MY_DATE TIMESTAMP
    +);+
    insert into my_table values ('P3XGL2FV96', 'Test 1', '11-AUG-10 03.38.06.000000000 PM');
    insert into my_table values ('1VGJ74PSNW', 'Test 2', '12-AUG-10 09.49.09.000000000 AM');
    insert into my_table values ('1VGJ74PSNW', 'Test 2', '11-AUG-10 04.02.22.000000000 PM');
    commit;
    SELECT id, title, my_date
    FROM (SELECT id,
    title,
    my_date,
    RANK () OVER (PARTITION BY id ORDER BY my_date DESC) rk
    FROM my_table)
    WHERE rk = 1;
    ID        |TITLE     |MY_DATE
    ----------|----------|---------------------------------------------------------------------------
    +1VGJ74PSNW|Test 2 |12-AUG-10 09.49.09.000000 AM+
    P3XGL2FV96|Test 1    |11-AUG-10 03.38.06.000000 PM
    Remark : if one id have twice the same date they will be both ranked first
    Kind regards,
    Ludovic
    Edited by: ludovic.sz on Aug 12, 2010 8:38 AM

  • Query for select statement

    Dear all
    is there any option in select statement to automatically generate serial number respect of data.
    for eg.
    1 101100110  shetal trade
    2 1110001178 CHEMICAL SOAP WORKS
    3..
    4..
    i don't  want to use loop (sy-tabix) ..
    thanks,
    Abhi

    Hi ,
    i don't want to use loop (sy-tabix) ..
    any particular reason for this ?
    as u cannot automatically generate serial number, u have to go for loop....endloop.
    Thanks
    Karthik

  • Query for selecting current date when running report

    Hi all
    I need a query that will copy today's date on posted sales order via DTW then that query will be linked to an alert and be sent to the sales manager every morning after the import went through successfully.
    The report at the moment is running fine as i pulling through the other info required the only problem is it's pulling all the sales orrders on the system , we want it to pull only the days orders imported.

    You could use either of these queries
    SELECT T0.DocNum, T0.DocDueDate, T0.CardCode, T0.CardName, T0.DocTotal, T0.U_ROUTEMARKTN, T0.U_ROUNDS, T0.U_DAYOFWEEK
    FROM [dbo\].[ORDR\] T0
    WHERE T0.DocDate = GETDATE()
    ORDER BY T0.U_ROUTEMARKTN, T0.U_ROUNDS, T0.U_DAYOFWEEK, T0.DocDueDate
    OR
    SELECT T0.DocNum, T0.DocDueDate, T0.CardCode, T0.CardName, T0.DocTotal, T0.U_ROUTEMARKTN, T0.U_ROUNDS, T0.U_DAYOFWEEK
    FROM [dbo\].[ORDR\] T0
    WHERE DATEDIFF(Day, T0.DocDate, GETDATE()) = 0
    ORDER BY T0.U_ROUTEMARKTN, T0.U_ROUNDS, T0.U_DAYOFWEEK, T0.DocDueDate

  • Query for selecting the field of VBRK

    Hi All,
      I have fetched the Ztable into it_bauch.
    In the loop of It_bauch i have to fetch the records of vbrk in which the field of zuonr is wrongly stored in xblnr.
    while fetching VBRK the zuonr0(8) should be comapred with it_zbauch-xblnr2(8).
    select single * from vbrk where fkart = 'F2'
                                      and fktyp = 'L'
                                      and vbtyp = 'M'
                                      and rfbsk = 'C'
                                      and fksto = space.
                                 <b>  and ZUONR0(8)  = it_wabuch-xblnr2(8).</b>
    ZUONR0(8)  = it_wabuch-xblnr2(8).</b>
    the above line cannot be return so the below code is given whether it would work or not or any other solution kindly do respond
          data : begin of it_vbrk occurs 0.
                  include structure vbrk.
          data :  end of it_vbrk.
          data vbrk_flag type c.
    data : begin of wa_vbrk,
              zuonr(8) type c,
              end of wa_vbrk.
    loop at it_bauch.
    select single * from vbrk into  it_vbrk where fkart = 'F2'
                                      and fktyp = 'L'
                                      and vbtyp = 'M'
                                      and rfbsk = 'C'
                                      and fksto = space.
    loop at it_vbrk.
            wa_vbrk-zuonr  = it_vbrk-ZUONR+0(8).
            read table it_wabuch with key xblnr+2(8) = wa_vbrk-zuonr.
            if sy-subrc = 0.
              clear vbrk_flag.
              vbrk_flag = 'X'.
            endif.
            clear wa_vbrk-zuonr.
          endloop.
    if vbrl-zuonr  =  'X'.
    After lot of select querey are there based on above condition would trigger.
    endif.
    endloop.

    data : vxblnr(9).
    vxblnr = it_wabuch-xblnr+2(8).
    concatenate vxblnr '%' into vxblnr.
    select single * from vbrk where fkart = 'F2'
    and fktyp = 'L'
    and vbtyp = 'M'
    and rfbsk = 'C'
    and fksto = space.
    and ZUONR like vxblnr.
    regards
    shiba dutta

  • Attempting to use bluetooth for the first time, and it never sees any other devices

    I have an iPad 2 about a year old, running iOS 6.0.1.  This morning I tried to connect to another iPad, over bluetooth, and neither iPad is able to discover the other.  This is the first attempt to use bluetooth on either of these iPads.  The other iPad is also running iOS 6.0.1.  The iPads were less than 10 feet apart.
    On both devices, I went to settings:bluetooth, and turned blutooth "on".  This opened up a "Devices" box, which says "Searching...", with a spinning wheel icon. Below this box is says "Now discoverable".  Both devices remained in this state.
    I haven't used bluetooth before so I have no idea what I am doing wrong.
    Later in the day I fiddled with the bluetooth systems prefs panel on my desktop (a circa 2005 intel mac running OSX 10.6.8).

    (hadn't finished my earlier message but somehow it posted it before I was ready).
    From the OSX bluetooth panel, I turned bluetooth on, and made my computer discoverable.  I then hit "setup new device", and was taken to the Bluetooth setup assistant.  After a few seconds it showed me my ipad as one of the devices it had discovered.  Over on the ipad, though, it did not discover the desktop machine.
    After about a minute, I then selected the ipad from the list of devices on the desktop machine, and hit "continue".  At this point it said "attempting to pair with MyIpad", and "connection established".  At the same time, a panel popped up on my iPad, listing my desktop machines name, and asking for a PIN.  It is not clear to me whether it is asking for a PIN that I have supposedly set up on the desktop machine, or if it is asking me to establish a PIN.  So I quit.
    In any case, my goal in going through this attempt on the destop machine was solely to establish whether the bluetooth hardware is working on the ipad.  I believe that has to be true.
    So, can someone explain to me what steps I am *supposed* to go through to pair up two ipads over bluetooth?

Maybe you are looking for