Sql  Query . Please help its urgent.

Suppose in table EMP there are 2 columns (Roll_no and Name)
Roll NO Name
00001 A
00002 B
00010 X
My requirement is to trunc preceding Zero's. For ex : for Roll no: 00001 the output should be 1 and for 00002 --> 2 .
Please help its very urgent.

try this
      select
              to_number(roll_no) roll_no,
              name
      from
              emp;
     Regards
Singh

Similar Messages

  • SQL Query, please help very urgent

    I am a newbie is sql.
    I have two tables called test_master and test_detail.
    Both tables contains pos_id as common field.
    In test_detail got sub_id and to get the people under a given pos_id, I join with pos_id of test_master.
    In the where condition, when I give the pos_id, it's returning only
    the first level. How can I get the second level and get all the levels?
    Any help is highly appreciable.It's very urgent.
    Looking forward to hear from you.
    Thanks
    Newbie

    Ok, I am pasting the description of the master and detail in the order.
    Master
    EMPLOYEE_NO VARCHAR2(30)
    ORGANIZATION_ID NUMBER(15)
    ORGANIZATION_NAME VARCHAR2(240)
    POSITION_ID NUMBER(15)
    POSITION_NAME VARCHAR2(240)
    Detail
    POSITION_ID NUMBER(15)
    SUBORDINATE_ID NUMBER(15)
    ORGANIZATION_ID NUMBER(15)
    POSITION_NAME VARCHAR2(50)
    Here is the sql, I want to get all the subordinates under a given position_id of the master.
    Looking forward to hear from you.
    select a.employee_no,a.POSITION_ID,a.POSITION_NAME,a.EMPLOYEE_NAME,
    b.position_id,b.subordinate_id from portal_employee_master_test a,
    portal_structure_test b
    where a.POSITION_ID = b.POSITION_ID and a.POSITION_ID='xyz'
    and b.position_ID=a.POSITION_ID

  • Cluster bar chart- sql query please help-

    Hi,
    I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
    Here is my table
    city     region      issue     value
    c1     north     i1     y
    c1     north     i2     y
    c2     north     i1     n
    c2     north     i2     y
    c3     south     i1     y
    c3     south     i2     n
    c4     east     i1     n
    c4     east     i2     n
    The bar chart will have 3 series, north south and east.
    And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
    How can I get something like this from the above table-
    region     issue     count(yes)
    north     i1     1
    north     i2     2
    south     i1     1
    south     i2     0
    east     i1     0
    east     i2     0
    thanks

    WITH table1 AS
    (SELECT 1435177 qte_id, 2 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no
    FROM dual
    table2 AS
    SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
    FROM dual
    SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
    FROM
    (SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
    FROM table1 t1, table2 t2
    WHERE t2.qte_id = t1.qte_id (+)
    AND t2.seq_no = t1.seq_no(+)
    ORDER BY 1,2
    WHERE t1_seq_no IS NOT NULL
    ORDER BY 1,2
    QTE_ID T2_SEQ_NO DIFF
    1435177 2 0
    1435177 5 0
    1435177 7 0
    1435177 8 0
    1435177 12 0
    1435177 14 0

  • Passing parameter to a SQL query - Please help

    Hi All,
    I am new to JDBC. I have been trying to pass an external variable to an SQL Query.
    The query is
    String username1="le";
    PreparedStatement pstmt = null;
    pstmt = c.prepareStatement("select * from users where USER_NAME like '%?%'");
         pstmt.setString(1, username1);
         pstmt.executeQuery();
         ResultSet rs = pstmt.getResultSet();
    I am trying to retrieve values from the users table where the USER_NAME column value that is a String contains the supplied value username1.
    I am using the question mark (?) character to pass the value from the variable username1. I am also using the '%' substitution character which matches for any number of characters. So, the above query should retrieve rows where the USER_NAME is something like "charles","leander","Elena" etc.( that contains "le")
    I am getting the error:
    SQLException: java.sql.SQLException: ORA-01006: bind variable does not exist
    I changed the query to
    PreparedStatement pstmt = null;
    pstmt = c.prepareStatement("select * from users where USER_NAME like '% " + username1 + "%'");
         //pstmt.setString(1, username1);
         pstmt.executeQuery();
    This time , it is not giving the error and retrieving properly.
    But I want to use the original query and use the "pstmt.setString(1, username1); " . Is there any way of achieving this?
    Please help.
    Cheers,
    charles_am

    hi,
    try this...
    String username1="%le%";
    pstmt = c.prepareStatement("select * from users where USER_NAME like ?")
    pstmt.setString(1,username1);
    cheers,
    rpk

  • Single sql query-please help

    Hi experts,
    what i want to do is write a single query which will show whether a employee
    exits in the company or not.I have two tables emp and dept.There are as follows.
    SQL> select * from emp;
    NAME DEPTNO EMPNO
    xxx 10 33036
    YYY 12 2345
    ZZZ 13 678
    KKK 14 5678
    RRR 15 7865
    SQL> select * from dept;
    DEPTNO LOCATION
    10 AAA
    11 BBB
    12 CCC
    13 DDD
    what i want is it will select records from the emp table and find whether corrosponding
    deptno really exists in the dept table.If the value is found in deptno column the dept table then it will set the value
    Y other wise it will be N and all i have to do with the help of a single query.
    expected result
    name empno exists
    xxx 33036 Y
    YYY 2345 Y
    ZZZ 678 Y
    KKK 5678 N
    RRR 7865 N
    Please help.
    Regards
    Rajat

    SELECT EMPNO, NAME , EMPNO , NVL( ( SELECT 'Y' FROM    DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO),'N') EXIST
    FROM EMP
    ORDER BY 1
    Demo
    SQL> WITH EMP AS(
      2  SELECT 'XXX' NAME , 10 DEPTNO ,33036  EMPNO FROM DUAL UNION
      3  SELECT 'YYY', 12, 2345 FROM DUAL UNION
      4  SELECT 'ZZZ', 13 ,678 FROM DUAL UNION
      5  SELECT 'KKK', 14 ,5678 FROM DUAL UNION
      6  SELECT 'RRR', 15 ,7865 FROM DUAL  ),
      7  DEPT AS(
      8  SELECT 10  DEPTNO,'AAA' DNAME FROM DUAL UNION
      9  SELECT 11 ,'BBB' FROM DUAL UNION
    10  SELECT 12 ,'CCC' FROM DUAL UNION
    11  SELECT 13 ,'DDD'FROM DUAL )
    12  SELECT EMPNO, NAME , EMPNO , NVL( ( SELECT 'Y' FROM    DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO),'N')
    EXIST
    13  FROM EMP
    14  ORDER BY 1
    15  /
         EMPNO NAM      EMPNO E
           678 ZZZ        678 Y
          2345 YYY       2345 Y
          5678 KKK       5678 N
          7865 RRR       7865 N
         33036 XXX      33036 Y
    SQL> Edited by: Salim Chelabi on Dec 7, 2008 4:15 AM

  • SQL Query -- Please Help

    Table1
    QTE_ID     SEQ_NO
    1435177     2
    1435177     5
    1435177     7
    1435177     8
    1435177     12
    1435177     14
    Table2
    QTE_ID     SEQ_NO     CMMT_CURR_AMT
    1435177     1     98500
    1435177     2     98500
    1435177     3     0
    1435177     4     98500
    1435177     5     98500
    1435177     7     98500
    1435177     8     98500
    1435177     11     59300
    1435177     12     59300
    1435177     14     59300
    The result should be
    QTE_ID     SEQ_NO     CMMT_CURR_AMT
    1435177     2     0 (where 0 = cmmt_curr_amt of seq 2 - cmmt_curr_amt of seq 1 from table 2)
    1435177     5     0 (where 0 = cmmt_curr_amt of seq 5 - cmmt_curr_amt of seq 4 from table 2)
    1435177     7     0 (where 0 = cmmt_curr_amt of seq 7 - cmmt_curr_amt of seq 5 from table 2)
    1435177     8     0 (where 0 = cmmt_curr_amt of seq 8 - cmmt_curr_amt of seq 7 from table 2)
    1435177     12     0 (where 0 = cmmt_curr_amt of seq 12 - cmmt_curr_amt of seq 11 from table 2)
    1435177     14     0 (where 0 = cmmt_curr_amt of seq 14 - cmmt_curr_amt of seq 12 from table 2)
    I have to get the difference of cmmt_curr_amt from the table2 from seq 14 to seq 12 for seq14 in table 1.
    Please help me in writing the query.
    Thanks in advance.
    Srinivas

    WITH table1 AS
    (SELECT 1435177 qte_id, 2 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no
    FROM dual
    table2 AS
    SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
    FROM dual
    SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
    FROM
    (SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
    FROM table1 t1, table2 t2
    WHERE t2.qte_id = t1.qte_id (+)
    AND t2.seq_no = t1.seq_no(+)
    ORDER BY 1,2
    WHERE t1_seq_no IS NOT NULL
    ORDER BY 1,2
    QTE_ID T2_SEQ_NO DIFF
    1435177 2 0
    1435177 5 0
    1435177 7 0
    1435177 8 0
    1435177 12 0
    1435177 14 0

  • Please Help its Urgent ***POPUP at the time of MIGO Posting*****

    Hi all,
    Please help me on this issue,
    I want to display one popup at the time of migo posting and that popup ask to user that " How much labels you wants to print?" and in next of that i want one text box or input field in that user inputs the number of labels he wants to print.
    I have tried using various POPUP functions but i have not got any FM which fulfill my requirement so please help me on this issue?
    Kind Regards
    Sudarshan Gaikwad

    The standart POPUP* function modules seem to either give an option to output descriptive text, or ask for a dictionary based field as an input.  As you want both in one popup you may need to write your own custom pop-up.
    Create a function group with a Z function module and add a dialog screen with the required text and input field to this function group.
    Take a look at function POPUP_GET_VALUES as an example - A custom written one could be a lot simpler.
    Then call this function from your user exit.
    Andrew

  • I need to denormalize data in sql query, please help!

    With the query
    select ref, start_time, end_time, person
    from appointments
    I get, eg:
    REF START_TIME END_TIME PERSON
    1234 10:00 11:00 USER1
    1234 10:00 11:00 USER2
    The users want to see it like this:
    REF START_TIME END_TIME PERSON
    1234 10:00 11:00 USER1, USER2
    How do I do this just in sql?
    cheers
    Tracey.

    Apologies, my mistake, I forgot to connect by the ref as well...
    (Note: you can ignore the CAST to VARCHAR2(40) as that just helped me get the formatted output.)
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 1234 as ref, '10:00' as start_time, '11:00' as end_time, 'USER1' as person from dual union all
      2             select 1234, '10:00', '11:00', 'USER2' from dual union all
      3             select 345, '11:00', '12:00', 'USER3' from dual)
      4  -- END OF TEST DATA
      5  select ref, start_time, end_time, CAST(MAX(LTRIM(SYS_CONNECT_BY_PATH(person,', '),', ')) AS VARCHAR2(40)) as users
      6  from (select ref, start_time, end_time, person
      7              ,row_number() over (partition by ref, start_time, end_time order by person) rn
      8        from t) t
      9  CONNECT BY rn = PRIOR rn+1 AND ref = PRIOR ref
    10  START WITH rn = 1
    11* GROUP BY ref, start_time, end_time
    SQL> /
           REF START END_T USERS
          1234 10:00 11:00 USER1, USER2
           345 11:00 12:00 USER3
    SQL>

  • PLEASE HELP ITS URGENT (PROBLEM IN INCLUDE)

    IF I EXECUTE IN 4.6C ITS NOT GIVIN NY ERROR BUT THE SAME CODE IN 6.0 IS GIVING ERROR
    IF NOT ( ( text_flag = 'X' AND tcode_level > 0 ) OR
                 ( text_flag_level0 = 'X' AND
                   tcode_level      = 0   AND          )    ).
    ERROR IS:
    Incorrect logical expression: "AND" or "OR" must be preceded by an          
    expression (e.g. a comparison).          
    PLZ HELP ME AS IT IS VERY URGENT.
    THANX IN ADVANCE

    Hi anit,
    1. minor mistake
    2. remove this AND in bold.
    IF NOT ( ( text_flag = 'X' AND tcode_level > 0 ) OR
    ( text_flag_level0 = 'X' AND
    tcode_level = 0 <b>AND</b> ) ).
    regards,
    amit m.

  • Problem with client side printing, please help its urgent

    hi ,
    am using struts and jasper reports on my project, now i was having problem that whenever i try to print the report , the printer dialogue box was appearing on server machine, i want it on client end, how to solve this problem, please any one know help me, it was urgent,
    my code was like this
    JasperCompileManager.compileReportToFile("c:/report/test.jrxml","c:/report/test.jasper");
    JasperPrint jasperPrint = JasperFillManager.fillReport("c:/report/test.jasper"),parameters,con);
    List l=jasperPrint.getPages();                         
    if(l.size() != 0){
      jasperPrint.setOrientation(JasperReport.ORIENTATION_PORTRAIT);
      jasperPrint.setPageHeight(877);
      jasperPrint.setPageWidth(963);
      JasperPrintManager.printPages(jasperPrint,0,l.size()-1,true);
    }thanks in advance,

    Double post.

  • Iphone 5 troubles, please help, its urgent!

    I got this new iphone 5, but i wanted my music and photos to go on it from my ipod 4th generation, so i connected my ipod to my computer and itunes and backed it up, when i plugged in my iphone, its said to back it up (hoping my files would transfer like it intended it would, i did so) .. except it turned my iphone 5 into an ipod, they layout was the same, the settings were the same, please i need help and i want to see my iphone back to the way i had it when i got it earlier today. I've tried all the resets and it still won't work

    Download the ipsw for your iphone, then open itunes and press shift (on windows) or option (on Mac), while holding that button click on restore, then you can selecte where to restore from, select the file you just downloaded, make sure is the latest version, and check if your phone is CDMA or GSM before downloading the file.
    You might be able to find the ispw on google

  • Please Help its urgent........requirement is to read a .gz file

    and to randomly acces it...
    If i read the file line by line using GZIPInputStream it takes lot of time...
    My requirement is to pick some line (say 35000) randomly......
    Please suggest any alternative.....

    use this code to unzip a .gzip file:
    try {
            // Open the compressed file
            String inFilename = "infile.gzip";
            GZIPInputStream in = new GZIPInputStream(new FileInputStream(inFilename));
            // Open the output file
            String outFilename = "outfile";
            OutputStream out = new FileOutputStream(outFilename);
            // Transfer bytes from the compressed file to the output file
            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            // Close the file and stream
            in.close();
            out.close();
        } catch (IOException e) {
        }

  • RegEx Error for Huge File .. Please help , Its Urgent

    Hi all,
    I am getting following exception,
    does anyone know about it
    java.lang.IndexOutOfBoundsException: No group 1
    at java.util.regex.Matcher.group(Matcher.java:355)
    at java.util.regex.Matcher.appendReplacement(Matcher.java:585)
    at java.util.regex.Matcher.replaceFirst(Matcher.java:701)
    at XSLT_OnlyJava.<init>(XSLT_OnlyJava.java:84)
    at XSLT_OnlyJava.main(XSLT_OnlyJava.java:93)
    Exception in thread "main"
    I am parsing huge file with regex and replacing some part
    Thanks,
    Vinayak

    sorry for late
    This is my code
    text = contents.toString();
              String regex = "<tu.*?/tu>";
              Matcher matcher = Pattern.compile(regex,Pattern.CASE_INSENSITIVE|Pattern.DOTALL).matcher(text);
              while(matcher.find()){
                   tuvSegment = matcher.group();
                   String segRegex = "<seg>.*?</seg>";
                   Matcher segMatcher = Pattern.compile(segRegex,Pattern.CASE_INSENSITIVE|Pattern.DOTALL).matcher(tuvSegment);
                   if(segMatcher.find()){
                        SegVal = segMatcher.group();
                   String ReplsegRegex = "<seg />";
                   Matcher ReplsegMatcher = Pattern.compile(ReplsegRegex,Pattern.CASE_INSENSITIVE|Pattern.DOTALL).matcher(tuvSegment);
                   text = ReplsegMatcher.replaceFirst(SegVal);
    The text string contains teh .tmx file
    Thanks,
    Vinayak

  • I need sql query please help me out

    I have two databases 1) erp 2) edusource
    In erp database i  have table  master tables and  columns  like RecordId , value type ,Feildtext,description,Meaining,parentid etc
     data stores based on value type like
    1
    Country
    In
    India
    NULL
        NULL
    True
    2
    Country
    Aus
    Austrilia
    NULL
        NULL
    True
    3
    Country
    Usa
    United States of America
    NULL
        NULL
    True
    4
    Country
    Uk
    Great Britian
    NULL
        NULL
    True
    5
    State
    AP
    Andhrapradesh
    NULL
         1
    True
    6
    State
    MH
    Maharastha
    NULL
         1
    True
    7
    State
    TN
    Tamilnadu
    NULL
         1
    True
    8
    State
    Sdy
    Sydney
    NULL
         2
    True
    9
    State
    MEL
    Melbourne
    NULL
    2
    True
    10
    Location
    IN-Hyd
    Hyderabad
    NULL
    1
    True
    11
    Location
    In SEz
    Sez-Hyderabad
    NULL
    1
    True
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    for  country and state we have a relation ship parentid and recordid
    country
    1 Country
    In India
                                       NULL
    NULL 1
    2 Country
    Aus Austrilia
                               NULL
    NULL 1
    3 Country
    Usa United States of America    NULL
    NULL 1
    4 Country
    Uk Great Britian
                    NULL
    NUL          1 
    5 State
    AndhraPradesh Ap
    NULL 1
    1
    6 State
    Maharastha MH
    NULL 1
    1
    7 State
    Tamilnadu        TN
    NULL        1
    1
    8 State
    Sydney            Sdy   NULL
          2 1
    9 State        Melbourne       MEL
    NULL       2
    1
      in edusource  database i have location and columns like countryname,statename,feildtext,descriptiom,isactive
    i need to insert data in edusource
     database of tbl_ maplocation from that that database

    Try this out:
    DECLARE @geog TABLE (ID INT, type VARCHAR(20), Abrev VARCHAR(6), name VARCHAR(30), parentID INT, Active VARCHAR(5))
    INSERT INTO @geog (ID, type, Abrev, name, parentID, Active) VALUES
    (1 , 'Country' ,'In ', 'India ', NULL, 'TRUE'),(2 , 'Country' ,'Aus ', 'Austrilia ', NULL, 'TRUE'),
    (3 , 'Country' ,'Usa ', 'United States of America', NULL, 'TRUE'),(4 , 'Country' ,'Uk ', 'Great Britian ', NULL, 'TRUE'),
    (5 , 'State' ,'AP ', 'Andhrapradesh ', 1 , 'TRUE'),(6 , 'State' ,'MH ', 'Maharastha ', 1 , 'TRUE'),
    (7 , 'State' ,'TN ', 'Tamilnadu ', 1 , 'TRUE'),(8 , 'State' ,'Sdy ', 'Sydney ', 2 , 'TRUE'),
    (9 , 'State' ,'MEL ', 'Melbourne ', 2 , 'TRUE'),(10 , 'Location' ,'IN-Hyd', 'Hyderabad ', 1 , 'TRUE'),
    (11 , 'Location' ,'In SEz', 'Sez-Hyderabad ', 1 , 'TRUE')
    SELECT g1.ID, COALESCE(g2.name,g1.name) AS countryName, g1.name AS stateName, g1.name AS fieldText, CASE WHEN COALESCE(g2.Active,'TRUE') = 'TRUE' AND g1.Active = 'TRUE' THEN 'TRUE' ELSE 'FALSE' END AS Active
    FROM @geog g1
    LEFT OUTER JOIN @geog g2
    ON g1.parentID = g2.ID
    AND g1.type IN ('location','state')
    WHERE g1.Active = 'TRUE'
    AND COALESCE(g2.Active,'TRUE') = 'TRUE'
    I think you may want to further the relationship, and have 10 be the parent for 11, so you can get country, state, location.

  • SQL experts please help for a query

    I have following table1.
    What query can give the result as given below, SQL experts please help on this.
    TABLE1
    Event DATETIME
    in 2/JAN/2010
    out 2/JAN/2010
    in 13/JAN/2010
    out 13/JAN/2010
    in 5/JAN/2010
    out 5/JAN/2010
    RESULT REQUIRED FROM THE SQL QUERY
    COL1_IN COL2_OUT
    2/JAN/2010 2/JAN/2010
    13/JAN/2010 13/JAN/2010
    5/JAN/2010 5/JAN/2010

    I tried to help, but this puzzles me.
    Why is this not returning pre-selected set of rows, why it's doing some merge join cartezian ?
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> select * from table1;
    EVENT      DATETIME
    in         2/JAN/2010
    out        2/JAN/2010
    in         13/JAN/2010
    out        13/JAN/2010
    in         5/JAN/2010
    out        5/JAN/2010
    6 rows selected.
    SQL> explain plan for
      2  with a as
    (select datetime from table1 where event='in'),
    b as
    (select datetime from table1 where event='out')
    select  a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
    Explained.
    SQL> set wrap off
    SQL> set linesize 200
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 185132177
    | Id  | Operation            | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |        |     9 |   288 |     8   (0)| 00:00:01 |
    |   1 |  MERGE JOIN CARTESIAN|        |     9 |   288 |     8   (0)| 00:00:01 |
    |*  2 |   TABLE ACCESS FULL  | TABLE1 |     3 |    48 |     3   (0)| 00:00:01 |
    |   3 |   BUFFER SORT        |        |     3 |    48 |     5   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL | TABLE1 |     3 |    48 |     2   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - filter("EVENT"='in')
       4 - filter("EVENT"='out')
    Note
       - dynamic sampling used for this statement
    21 rows selected.
    SQL> with a as
    (select datetime from table1 where event='in'),
    b as
    (select datetime from table1 where event='out')
    select  a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
    COL1_IN         COL2_OUT
    2/JAN/2010      2/JAN/2010
    2/JAN/2010      13/JAN/2010
    2/JAN/2010      5/JAN/2010
    13/JAN/2010     2/JAN/2010
    13/JAN/2010     13/JAN/2010
    13/JAN/2010     5/JAN/2010
    5/JAN/2010      2/JAN/2010
    5/JAN/2010      13/JAN/2010
    5/JAN/2010      5/JAN/2010
    9 rows selected.
    SQL>

Maybe you are looking for

  • Entire contents of folder missing

    I was copying a folder of music (a specific CD that I have on another drive) into my iTunes library and rec'd an error msg (I didn't pay much attention to it). When I looked to see if the music was transferred into my iTunes I noticed that the songs

  • Re: Satellite L750 - advanced mouse settings are not working properly

    Satellite L750 model (One month old). The problem is that every time I start the computer, only works the point device of the mouse synaptics , but retains the advanced settings as pressing with three fingers, turns or you can use the wheel to move u

  • How to uninstall third-party visualizers on iTunes?

         To be specific I cannot uninstall the visualizer "Cubism". It required that I put a qtz file (Cubism) into a folder called "Compositions" (already provided for in the little window you open from the dmg) and then drag it into ~/Library/Compositi

  • HT2534 Management of epub books (in iBook) which are invisable in iTunes

    I have downloaded books in epub format to iBook from my newspaper provider. They are not visable in iTunes. How do I make them visable, do back up of them or move them to another Apple device e.g. a iPad Mini or PC? Thanks in advance/khn

  • Components Do the Wrong thing.... (listbox and datatable)

    Okay - this one may be a "don't do that" but here goes.... Create a new project. On Page1. Drag a DataTable out, drop a Table on it. (should fill out the columns, yes?) It does. Now, in Project Navigator, create a new folder (foo) in the WebPages fol