Looking for a SQL statement

Looking for a sql statement that returns me one row which is made up of data of two rows but display it side by side instead of one row followed by other row.
e.g
Col1
1
2
2 Rows selected
How can i display it as
Col1
1 2
1 Row selected
Appreciate any responses.
TIA
DS
null

How to find the last sql statement executed in oracle .
thanks
B.B.Padhi
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by SANJAY KUMAR ([email protected]):
i have table san with column rl having values 11, 12. Then write the SQL as:
select a.rl, n.rl from san a,( select b.rl from san b where b.rl in (select rl from san) ) n
where a.rl < n.rl;
It will give u approprate result.
Thanks!<HR></BLOCKQUOTE>
null

Similar Messages

  • Looking for and SQL query to match CTI OS agent login ID with the Directory Number (instrument)

    Hi All,
    I am looking for an SQL query to request the HDS database to find out which Directory Number / instrument  was associated with a specific CTI OS agent login ID.
    Has anyone done such a query before ?
    Thanks and Regards
    Nick

    Hi,
    this should work in 8.0 and 8.5:
    SELECT
    ag.PeripheralNumber AS [LoginID],
    al.Extension,
    al.LogoutDateTime
    FROM [instance]_hds.dbo.Agent_Logout al
    JOIN [instance]_awdb.dbo.Agent ag ON al.SkillTargetID = ag.SkillTargetID
    Of course, replace [instance] with the ICM instance.
    The query returns a table with three columns, first is the login ID aka PeripheralNumber, Extension is... well, the agent's extension, and LogoutDateTime is the timestamp when the agent logged out.
    G.

  • Looking for an SQL query to retreive callvariables + ECC from a RUN SCRIPT RESULT (Translation to VRU)

    Hi Team,
    I am looking for an SQL query to check the data (ECC + CallVariable) received following a RUN SCRIPT RESULT when requesting an external VRU with a Translation Route to VRU with a "Run External Script".
    I believe the data are parsed between the Termination Call Detail + Termination Call Variable .
    If you already have such an SQL query I would very much appreciate to have it.
    Thank you and Regards
    Nick

    Omar,
    with all due respect, shortening a one day's interval might not be an option for a historical report ;-)
    I would recommend to take a look the following SQL query:
    DECLARE @dateFrom DATETIME, @dateTo DATETIME
    SET @dateFrom = '2014-01-24 00:00:00'
    SET @dateTo   = '2014-01-25 00:00:00'
    SELECT
    tcv.DateTime,
    tcd.RecoveryKey,
    tcd.RouterCallKeyDay,
    tcd.RouterCallKey,
    ecv.EnterpriseName AS [ECVEnterpriseName],
    tcv.ArrayIndex,
    tcv.ECCValue
    FROM Termination_Call_Variable tcv
    JOIN
    (SELECT RouterCallKeyDay,RouterCallKey,RecoveryKey FROM Termination_Call_Detail WHERE DateTime > @dateFrom AND DateTime < @dateTo) tcd
    ON tcv.TCDRecoveryKey = tcd.RecoveryKey
    LEFT OUTER JOIN Expanded_Call_Variable ecv ON tcv.ExpandedCallVariableID = ecv.ExpandedCallVariableID
    WHERE tcv.DateTime > @dateFrom AND tcv.DateTime < @dateTo
    With variables, you can parametrize your code (for instance, you could write SET @dateFrom = ? and let the calling application fill in the datetime value in for you).
    Plus joining two large tables with all rows like you did (TCD-TCV) is never a good option.
    Another aspect to consider: all ECC's are actually arrays (always), so it's not good to leave out the index value (tcv.ArrayIndex).
    G.

  • Escaping "curly apostrophe" for a sql statement

    Hi,
        I'm trying to escape the curly apostrophe for a sql statement, i.e.,
    Bob’s . I tried using the following
    string str = inputStr.Replace("'","''");
    Of course, this doesn't work.
    Thanks!

    Replace has 2 overloads.  One uses 2 strings while the other uses 2 char parameters.  Run this code on text pasted from each application.
    static string ReplaceString()
    string input =
    "O'Hara";
    foreach ( Char c
    in input )
    Console.WriteLine(c.ToString() +
    " = " + Convert.ToInt32(c).ToString());
    return input.Replace("'",
    String.Empty);
    Compare the values returned for the character.  Then use the char value from Word and replace it with the char value from Notepad in the other overload that takes 2 char parameters.
    Are you using a TextBox or a RichTextBox?
    Mark the best replies as answers. "Fooling computers since 1971."
    http://rudedog2.spaces.live.com/default.aspx

  • The number of reloads for the SQL statements

    Hi,
    in 10g R2, how to see the number of reloads for the SQL statements ? Any query ? Which value is high ? Which valu is low ?
    Thanks.

    thanks all.
    It was a test question for 1Z0-042 exam as follows :
    The users on your SALESDB are complaining of slow response to their queries. Using the SQL Tuning Advisor, you determine
    that the SQL statements are using the best optimization plan. Querying the dynamic views, you see that the number of reloads
    for the SQL statements is high, which can cause performance degradation.
    Which component of the SGA should you resize to reduce the number of reloads of the SQL statements?
    Answer :
    shared poolThen I wonder how to see the number of reloads for the SQL ?

  • How can I open a cursor for dynamic sql statement

    Hi,
    I'm facing issues opening a cursor for dynamic sql statement : PLS-00455: cursor 'RESULT1' cannot be used in dynamic SQL OPEN statement.
    CREATE OR REPLACE FUNCTION DEMO
    (MN_I in VARCHAR)
    return AB_OWNER.ABC_Type.NonCurTyp is
    RESULT1 AB_OWNER.ABC_Type.NonCurTyp;
    sql_stmt VARCHAR2(4000);
    BEGIN
    sql_stmt := 'SELECT * FROM AB_OWNER.DUN WHERE JZ_I in ('||mn_i||') ORDER BY app.ACC_I';
    OPEN RESULT1 FOR sql_stmt;
    END IF;
    return RESULT1;
    END DEMO;
    What changes should I make in the code so that it doesn't fail? I can't change the definition of RESULT1 cursor though.

    Gangadhar Reddy wrote:
    I used SYS REFCURSOR and was able to implement successfully.How many times did you run this successful implementation that does not use bind variables?
    Because this is what will happen when it runs a lot.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17766/e2100.htm#sthref1874
    http://forums.oracle.com/forums/search.jspa?q=%2BORA-04031%20%2Bbind&objID=c84&dateRange=all&rankBy=10001&start=30
    And you will have to regularly restart the server, or possibly slightly less invasive, flush the shared pool.
    Flushing Shared Pool regularly
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1516005546092
    >
    Ok, this is an easy one to diagnose.
    You are not using bind variables. This is terrible. Flushing the shared pool is a bad
    solution -- you are literally killing the performance on your box by not using them.
    If I was to write a book on how to build “non scalable applications in Oracle”, this
    would be the first and last chapter. This is a major cause of performance issues and a
    major inhibitor of scalability in Oracle. The way the Oracle shared pool (a very
    important shared memory data structure) operates is predicated on developers using bind
    variables. If you want to make Oracle run slowly, even grind to a total halt – just
    refuse to use them.
    >
    But, please feel free to go ahead with this successful implementation.
    I just hope anyone else who reads this doesn't make the same mistake.

  • Looking for MS SQL Server(2012 or older versions) all commands

    HI,
    Looking for MS SQL Server(2012 or older versions) all commands, i.e., all available sql server commands.
    Is there any reference manual or MS KL to get all commands in SQL Server ?
    Thanks in advance

    Thanks for link
    Sean Gallardy and Jingyang Li.
    This is is not usefull for my requirement.
    What i am looking is..SQL Server commands  like examples... DDL/DML comands...create/alter
    Examples: Insert/update/delete,truncate.......etc
    Create database,create procedure.......etc
    Alter database,shutdown,drop,create....etc
    Looking for list of all commands in one place/doc in SQL Server.
    Thanks

  • I am looking for a sql analyzer tool.

    I am looking for a sql analyzer tool that can analyze the speed of two queries...

    You mean like autotrace, set timing on, or alter session set events '10046 trace name context forever, level 12' , or you can write your own test harness. Depends upon what you want, exactly. Wall time, cpu time, average over 100 executions? Max time during busiest time of day in the database. Min time during quietest time of day in the database.
    A simple test harness like this might be sufficient.
    declare
    l_start number;
    begin
    l_start := dbms_utility.get_time;
    -- do your query here
    dbms_output.put_line( (dbms_utility.get_time-l_start) || ' hsecs' );
    end;
    Edited by: ajallen on Jan 12, 2010 11:28 AM

  • Where to look for the computed stats collected using gather_table_stats

    I have used analyze command before but new to gather_table_stats.
    I have executed gather_table_stats procedure as given below. Now where to look for the statistics estimated and also what are the important parameters I need to look in the stats ? Any major difference between analyze & gather_table_stats ?
    SQL> exec dbms_stats.gather_table_stats(ownname => 'TPDBS01A', tabname => 'x_TPD_STG_TL_SF_LEGAL_OWN
    ER' , estimate_percent => 50, method_opt => 'for all indexed columns size auto');
    PL/SQL procedure successfully completed.

    The command "analyze table" is deprecated for gathering optimizer statistics. But it is still the only command to get for instance the chained rows. This command is no longer maintained for new features, so if you use this command to collect statistics, it might not collect all needed numbers for the optimizer so the plan could be wrong.
    The package dbms_stats is collecting all the figures that the optimizer needs to genererate an optimal access plan. All new database features are incorporated only here.
    The statistics numbers can be found in the normal tables like USER|ALL|DBA_TABLES, ...TAB_COLUMNS, ...INDEXES, ...IND_COLUMNS etc. There you can find for instance number of rows in table, clustering factor for indexes and more numbers like this. They are not really needed for us human beings, they are used by the optimizer to generate the access plan.

  • ABAP Standards for a SQL statement

    Hi,
    I have a Native SQL statement in my ABAP user exit, pls. edit into a Open SQL,
    SELECT v1~tknum v1~tsnum
          INTO TABLE t_vtts
          FROM vtts AS v1
          FOR ALL ENTRIES IN t_shipment_del
          WHERE v1~tknum = t_shipment_del-tknum AND
                v1~vstel = rv_shppt          AND
                v1~kunnz = rv_shipto         AND
                v1~tsrfo = c_one             AND
                EXISTS ( SELECT addrnumber
                           FROM adrc CLIENT SPECIFIED
                           WHERE client     =  v1~mandt AND
                                 addrnumber =  v1~adrnz AND
                                 date_from  <= sy-datum AND
                                 date_to    >= sy-datum AND
                                 post_code1 =  rv_post_code1 ).
    Thank you

    Hhmm, for proper performance analysis we'd need some further details. Looking at your query I doubt that the following alternative helps, but you can give it a try, because subqueries are not always optimal:
      SELECT tknum tsnum INTO TABLE t_vtts
             FROM vtts INNER JOIN adrc ON
                  vtts~adrnz = adrc~addrnumber
             FOR ALL entries IN t_shipment_del
             WHERE tknum      = t_shipment_del-tknum AND
                   vstel      = rv_shppt             AND
                   kunnz      = rv_shipto            AND
                   tsrfo      = c_one                AND
                   post_code1 = rv_post_code1.
    You might need to add the condition on the address dates, but in any system I've checked so far, the ADRC-FROM date was always 00010101 and there was only one entry per address number (so if required, add it back).
    For performance tuning requests you should try to provide some background information, like:
    <ol>
    <li>How many entries are you your table T_SHIPMENT_DEL</li>
    <li>How many entries match your conditions on VTTS</li>
    <li>How many entries get dropped because of the condition on postal code</li>
    <li>Do a SQL trace and provide information about the execution plan chosen by the database</li>
    </ol>
    Also, you might want to consider moving your question to the forum.
    Cheers, harald

  • Explain plan for a sql statement

    Hi,
    I have a simple sql statement which has a cost of 122, cardinality 59 and CPU cost 1966777.
    Same sql statement written in another way (using a nested select in the 'from' clause), has a cost of 58, cardinality 24 but cpu cost is much higher 29078895.
    What should I look for? For a better cost overall, or for a better cpu cost? Which statement should I consider? What is most important?
    Thanks.

    Roger25 wrote:
    ... Based on this, my question is what statement to choose? which is more important, the cost or the cpu cost?
    Thanks.
    Based on this, sorry, but my reply will remain unchanged:
    Again, you cannot compare explain plan of two different queries.
    Find out more:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:313416745628
    Nicolas.

  • Looking for gaps (SQL, not PL/SQL)

    Hi,
    This is a SQL (not PL/SQL) question.
    Let's say I have the following table:
    COLtype          COLnumber
    AA               1
    AA               2
    AA               4
    AA               5
    BB               1
    BB               2
    BB               3
    BB               5
    CC               1
    CC               5
    How do I find all gaps? I expect a result:
    COLtype          COLnumber
    AA               3
    BB               4
    CC               2
    CC               3
    CC               4
    I tried to use query:
    SELECT COLnumber + 1, COLtype FROM table a1
    WHERE NOT EXISTS (
    SELECT NULL FROM table a2
         WHERE
    a1.COLtype = a2.COLtype
    and (a2.COLnumber = a1.COLnumber + 1)
    but I received as result:
    COLtype          COLnumber
    AA               3
    AA               6
    BB               4
    BB               6
    CC               2
    CC               3
    CC               4
    CC               6
    Any other solutions, ideas?
    Thanks in advance!
    Gaspar
    Edited by: 985540 on 2013-02-01 02:59

    First let define gaps. If we have:
    COLtype COLnumber
    AA      3
    AA      4Are:
    COLtype COLnumber
    AA      1
    AA      2missing? If so is there an assumption COLnumber always starts with 1 or we just looking for gaps between existing numbers? For now I'll assume we are looking for gaps between existing numbers. Then:
    with t as (
               select  coltype,
                       colnumber,
                       lag(colnumber,1,colnumber - 1)
                         over(
                              partition by coltype
                              order by colnumber
                             ) prev_colnumber
                 from  tbl
    select  coltype,
            colnumber - column_value colnumber
      from  t,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level < colnumber - prev_colnumber
                       as sys.OdciNumberList
      where colnumber - prev_colnumber > 1
      order by coltype,
               colnumber
    CO  COLNUMBER
    AA          3
    BB          4
    CC          2
    CC          3
    CC          4
    SQL> explain plan for
      2  with t as (
      3             select  coltype,
      4                     colnumber,
      5                     lag(colnumber,1,colnumber - 1)
      6                       over(
      7                            partition by coltype
      8                            order by colnumber
      9                           ) prev_colnumber
    10               from  tbl
    11            )
    12  select  coltype,
    13          colnumber - column_value colnumber
    14    from  t,
    15          table(
    16                cast(
    17                     multiset(
    18                              select  level
    19                                from  dual
    20                                connect by level < colnumber - prev_colnumber
    21                             )
    22                     as sys.OdciNumberList
    23                    )
    24               )
    25    where colnumber - prev_colnumber > 1
    26    order by coltype,
    27             colnumber
    28  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 1739894384
    | Id  | Operation                            | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                     |      | 81680 |  2552K|       |   991   (1)| 00:00:12 |
    |   1 |  SORT ORDER BY                       |      | 81680 |  2552K|  3216K|   991   (1)| 00:00:12 |
    |   2 |   NESTED LOOPS                       |      | 81680 |  2552K|       |   277   (1)| 00:00:04 |
    |*  3 |    VIEW                              |      |    10 |   300 |       |     4  (25)| 00:00:01 |
    |   4 |     WINDOW SORT                      |      |    10 |   170 |       |     4  (25)| 00:00:01 |
    |   5 |      TABLE ACCESS FULL               | TBL  |    10 |   170 |       |     3   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |   6 |    COLLECTION ITERATOR SUBQUERY FETCH|      |  8168 | 16336 |       |    27   (0)| 00:00:01 |
    |*  7 |     CONNECT BY WITHOUT FILTERING     |      |       |       |       |            |          |
    |   8 |      FAST DUAL                       |      |     1 |       |       |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - filter("COLNUMBER"-"PREV_COLNUMBER">1)
       7 - filter(LEVEL<:B1-:B2)
    PLAN_TABLE_OUTPUT
    Note
       - dynamic sampling used for this statement (level=2)
    25 rows selected.
    SQL> SY.

  • Need help for the sql statement !!!!!

    hi all,
    i need a sql statement for a query, how can i get the result from the rownum between 100 and 150?
    plz help

    use a scrollable statement:
    PreparedStatement stat = Connection.prepareStement("select * from blah", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stat.executeQuery();
    rs.absolute(100);
    while (rs.next()) {
    String something = rs.get(1);
    Look into the JDK API reference for ResultSet to get an expalantion of scrollable statements.

  • Look for official APPLE statement on future rSAP Bluetooth profile support

    Hi,
    My previous post was considered as "speculative" by the moderators (I still do not see what were the speculations but, OK, I let go)...
    Therefore, I'll try to be still more factual:
    _Fact 1_: current firmware of iPhone 3G does not support rSAP Bluetooth profile.
    _Fact 2_: my car needs my phone to support rSAP Bluetooth profile for being able to use the built-in handsfree kit.
    _Fact 3_: I cannot find anywhere an official statement from APPLE about this rSAP Bluetooth profile.
    _My question_: can someone give me a link to such an official statement?
    (I hope this will be considered as factual enough...

    Hello. I know this is not exactly what you are looking for. But the link below is a document that informs you about current BT Profile that is used.
    If you would like Apple to know about other BT Profiles needed to work with your car. Feel free to contact Apple via the feedback page below.
    iPhone Bluetooth Headset and third-party Bluetooth-enabled devices
    http://support.apple.com/kb/HT1841
    http://www.apple.com/feedback/iphone.html

  • Stored Procedures for Simple SQL statements

    Hi Guys,
    We are using Oracle 10g database and Web logic for frontend.
    The Product is previously developed in DotNet and SQL Server and now its going to develop into Java (Web Logic) and Oracle 10g database.
    Since the project is developed in SQL Server, there are lot many procedures written for simple sql queries. Now I would like to gather your suggestions / pointers on using procedures for simple select statements or Inserts from Java.
    I have gathered some list for using PL/SQL procedure for simple select queries like
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)
    Simple select statements are much faster than executing them from Procedure
    Pros
    Code changes for modifying select query in PL/SQL much easier than in Java
    Your help in this regard is more valuable. Please post your points / thoughts here.
    Thanks & Regards
    Srinivas
    Edited by: Srinivas_Reddy on Dec 1, 2009 4:52 PM

    Srinivas_Reddy wrote:
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)No entirely correct. All SQLs that hit the SQL engine are stored as cursors.
    On the client side, you have an interface that deals with this SQL cursor. It can be a Java class, a Delphi dataset, or a PL/SQL refcursor.
    Yes, cursors are created/opened at a huge rate by the SQL engine. But is is capable of doing that. What you need to do to facilitate that is send it SQLs that uses bind variables. This enables the SQL engine to simply re-use the existing cursor for that SQL.
    Simple select statements are much faster than executing them from ProcedureAlso not really correct. SQL performance is SQL performance. It has nothing to do with how you create the SQL on the client side and what client interface you use. The SQL engine does not care whether you use a PL/SQL ref cursor or a Java class as your client interface. That does not change the SQL engine's performance.
    Yes, this can change the performance on the client side. But that is entirely in the hands of the developer and how the developer selected to use the available client interfaces to interface with the SQL cursor in the SQL engine.
    Pros
    Code changes for modifying select query in PL/SQL much easier than in JavaThis is not a pro merely for ref cursors, but using PL/SQL as the abstraction layer for the data model implemented, and having it provide a "business function" interface to clients, instead of having the clients dealing with the complexities of the data model and SQL.
    I would seriously consider ref cursors in your environment. With PL/SQL servicing as the interface, there is a single place to tune SQL, and a single place to update SQL. It allows one to make data model changes without changing or even recompiling the client. It allows one to add new business logical and processing rules, again without having to touch the client.

Maybe you are looking for

  • Fn mod for date

    xperts, any fn mod available for getting dates like; if i am exec on Mon; Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat (10 days) if i am executing it on Wed. Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat (8 days) wat i need is th

  • How to read AL11 parameters in ABAP program

    Hello SAP Masters, I came across a requirement to read AL11 file parameters such as lastchanged day and lastchanged time of a particular file in directory. Can you guide me by providing either the function module name or any table where this informat

  • Can I have no transaction processing with esql (proc)?

    Hello all, I'm using embedded sql (via proc) and am trying to use the database without transaction processing. I am porting an application from Informix and this is possible with Informix . Is there some way to tell Oracle to autocommit or to turn of

  • Billed incorrectly!

    We have a holiday cottage that has a bt landline. The cottage is empty and in addition, the phone line is currently not working with a repair man due out next week! Despite this we have been billed for around £75 of calls just last month. I don't thi

  • Data not set when class is called

    can some one help me identify the mistake i made when i called new RMStorage("b1", 20000) in a file which is located at a subfolder of where this RMStorage.class is saved), the object is created, but given name=null and quantity=0. thanks in advance.