Please suggest a select query / under query with using any routines or

source table: three columns ORIGIN, DESTINATION, MILES

Origin Destination Miles

Sydney Melbourne 1000
Perth, Adelaide 3000
Canberra Melbounre 700
Melbourne Sydney 1000
Brisbane Sydney 1000
Perth, Darwin 4000
Sydney, Brisbane 1000

out put: three columns ORIGIN, DESTINATION, MILES

Duplicate routes should be ignored, so the output is

Origin Destination Miles

Sydney Melbourne 1000
Perth, Adelaide 3000
Canberra Melbounre 700
Brisbane Sydney 1000
Perth, Darwin 4000

Please suggest a select query / under query with using subroutines or functions/pkgs to get put out table.

Hello

user9368047 wrote:
... Please suggest a select query / under query with using subroutines or functions/pkgs to get put out table.

Why? If the most effective way to achieve the desired results is to use a function, why would you not use it?

Here's a way, without all the features:

SELECT     a.*
FROM           source_table  a
LEFT OUTER JOIN      source_table  b  ON   a.origin          = b.destination
                                      AND  a.destination       = b.origin
                      AND  a.miles          = b.miles
WHERE   b.origin  > a.origin    -- Not b.origin > b.origin
OR     b.origin  IS NULL
;

If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

Published by: Frank Kulash, November 6, 2012 19:39
Fixed WHERE after MLVrown clause (see below)

Tags: Database

Similar Questions

  • Please help improve the query with the analytic function

    The mentioned below query takes about 10 hours to complete (10.2.0.4).

    There are 3 tables (table t has a relationship 1: n with table e and k table also has a relationship 1: n with table e).
    Table a contains 200,000 lines. (this table is truncated and inserted several times a week)
    E table contains rows of 1Mio.
    K table contains rows of 170Mio.

    drop table t;
    create table t
    (
       t_id number,
       constraint t_pk primary key (t_id)
    );
    
    drop table e;
    create table e
    (
       e_id number,
       e_doc nvarchar2(16),
       e_date date,
       constraint e_pk primary key (e_id)
    );
    
    drop table k;
    create table k (
       t_id number,
       e_id number
    );
    
    create unique index k_i1 on k(t_id, e_id);
    
    exec dbms_stats.gather_table_stats(user, 'T');
    exec dbms_stats.gather_table_stats(user, 'K');
    exec dbms_stats.gather_table_stats(user, 'E');
    
    
    
    -- Sample data:
    
    insert into t(t_id) values (100);
    insert into t(t_id) values (101);
    insert into t(t_id) values (102);
    insert into t(t_id) values (103);
    
    
    insert into e(e_id, e_doc, e_date) values (200, 'doc 200', to_date('01.01.2010', 'DD.MM.YYYY'));
    insert into e(e_id, e_doc, e_date) values (201, 'doc 201', to_date('02.01.2010', 'DD.MM.YYYY'));
    insert into e(e_id, e_doc, e_date) values (202, 'doc 202', to_date('03.01.2010', 'DD.MM.YYYY'));
    insert into e(e_id, e_doc, e_date) values (203, 'doc 203', to_date('04.01.2010', 'DD.MM.YYYY'));
    insert into e(e_id, e_doc, e_date) values (204, 'doc 204', to_date('05.01.2010', 'DD.MM.YYYY'));
    insert into e(e_id, e_doc, e_date) values (205, 'doc 205', to_date('06.01.2010', 'DD.MM.YYYY'));
    insert into e(e_id, e_doc, e_date) values (206, 'doc 206', to_date('07.01.2010', 'DD.MM.YYYY'));
    insert into e(e_id, e_doc, e_date) values (207, 'doc 207', to_date('08.01.2010', 'DD.MM.YYYY'));
    
    insert into k(t_id, e_id) values (100, 200);
    insert into k(t_id, e_id) values (100, 201);
    insert into k(t_id, e_id) values (100, 202);
    insert into k(t_id, e_id) values (100, 203);
    
    insert into k(t_id, e_id) values (101, 203);
    insert into k(t_id, e_id) values (101, 204);
    
    
    
    
    
    select k.t_id, e.e_date,  e.e_id, e.e_doc
    from   e, k, t
    where  k.e_id = e.e_id
    and    k.t_id = t.t_id
    order by k.t_id, e.e_date desc;
    
    
          T_ID E_DATE         E_ID E_DOC
    ---------- -------- ---------- ----------------
           100 04.01.10        203 doc 203
           100 03.01.10        202 doc 202
           100 02.01.10        201 doc 201
           100 01.01.10        200 doc 200
           101 05.01.10        204 doc 204
           101 04.01.10        203 doc 203
    I need a query that takes the latest 3 posts for a given t_id:
          T_ID E_DOC_LIST
    ---------- -----------------------
           100 doc 200/doc 201/doc 202
           101 doc 203/doc 204
    
    
    Sample query:
    
    select t_id, e_doc_list
       from (
       select  k.t_id,
            row_number() over(partition by k.t_id order by k.t_id, e.e_date desc) r_num, 
            rtrim(       lag(e.e_doc, 0) over(partition by k.t_id order by k.t_id, e.e_date) || 
                  '/' || lag(e.e_doc, 1) over(partition by k.t_id order by k.t_id, e.e_date) || 
                  '/' || lag(e.e_doc, 2) over(partition by k.t_id order by k.t_id, e.e_date), 
                  '/') e_doc_list
         from  e,
               k,
               t
         where  k.e_id = e.e_id
         and    k.t_id = t.t_id
         order by k.t_id, e.e_date desc
    ) where  r_num = 1   ;
    
    
          T_ID E_DOC_LIST
    ---------- --------------------------------------------------
           100 doc 203/doc 202/doc 201
           101 doc 204/doc 203
    The example query takes several hours in production.
    The r_num = 1 filter is applied quite late. Is there another way to generate the query or even review the tables.
    For the sample query:
    
    -----------------------------------------------------------------------------------------
    | Id  | Operation                        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                 |      |     6 |   468 |     6  (50)| 00:00:01 |
    |*  1 |  VIEW                            |      |     6 |   468 |     6  (50)| 00:00:01 |
    |*  2 |   WINDOW SORT PUSHED RANK        |      |     6 |   216 |     6  (50)| 00:00:01 |
    |   3 |    WINDOW SORT                   |      |     6 |   216 |     6  (50)| 00:00:01 |
    |   4 |     NESTED LOOPS                 |      |     6 |   216 |     4  (25)| 00:00:01 |
    |   5 |      MERGE JOIN                  |      |     6 |   198 |     4  (25)| 00:00:01 |
    |   6 |       TABLE ACCESS BY INDEX ROWID| E    |     8 |   208 |     2   (0)| 00:00:01 |
    |   7 |        INDEX FULL SCAN           | E_PK |     8 |       |     1   (0)| 00:00:01 |
    |*  8 |       SORT JOIN                  |      |     6 |    42 |     2  (50)| 00:00:01 |
    |   9 |        INDEX FULL SCAN           | K_I1 |     6 |    42 |     1   (0)| 00:00:01 |
    |* 10 |      INDEX UNIQUE SCAN           | T_PK |     1 |     3 |     0   (0)| 00:00:01 |
    -----------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("R_NUM"=1)
       2 - filter(ROW_NUMBER() OVER ( PARTITION BY "K"."T_ID" ORDER BY
                  "K"."T_ID",INTERNAL_FUNCTION("E"."E_DATE") DESC )<=1)
       8 - access("K"."E_ID"="E"."E_ID")
           filter("K"."E_ID"="E"."E_ID")
      10 - access("K"."T_ID"="T"."T_ID")
    
    
    and for query in production
    
    ---------------------------------------------------------------------------------------
    | Id  | Operation                 | Name         | Rows  | Bytes |TempSpc| Cost (%CPU)|
    ---------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT          |              |  3118K|   425M|       |   160K  (1)|
    |   1 |  VIEW                     |              |  3118K|   425M|       |   160K  (1)|
    |   2 |   SORT ORDER BY           |              |  3118K|   163M|   383M|   160K  (1)|
    |   3 |    WINDOW SORT PUSHED RANK|              |  3118K|   163M|   383M|   160K  (1)|
    |   4 |     WINDOW SORT           |              |  3118K|   163M|   383M|   160K  (1)|
    |   5 |      HASH JOIN            |              |  3118K|   163M|    40M| 33991   (1)|
    |   6 |       TABLE ACCESS FULL   | E            |  1053K|    28M|       |  4244   (1)|
    |   7 |       NESTED LOOPS        |              |  3118K|    80M|       | 21918   (1)|
    |   8 |        TABLE ACCESS FULL  | T            |   144K|  1829K|       |   282   (2)|
    |   9 |        INDEX RANGE SCAN   | K_I1         |    22 |   308 |       |     1   (0)|
    ---------------------------------------------------------------------------------------
    
     

    TimWong765 wrote:
    ...
    Table a contains 200,000 lines. (* this table is truncated and inserted several times a week *)

    You could be in one of the rare cases where the index should be rebuild, take a look in the following thread:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:6601312252730 #69571308712887 (search for 'index of Sweeper')
    Make sure that you have checked if you are in this case before going for an expensive index rebuild.

    Nicolas.

  • Improve a simple select query that uses all the lines.

    Hi all

    Excuse me if the question is too dumb. Here is my code
    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    Elapsed: 00:00:00.07
    SQL> show parameter optim
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    object_cache_optimal_size            integer     102400
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.1
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    plsql_optimize_level                 integer     2
    
    SQL> explain plan for select SUM(decode(transaction_type,'D',txn_amount,0)) payments_reversals,
      2          SUM(decode(transaction_type,'C',txn_amount,0)) payments,primary_card_no,statement_date
      3             from credit_card_pymt_dtls  group by primary_card_no,statement_date;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------
    Plan hash value: 2801218574
    
    ----------------------------------------------------------------------------------------------------
    | Id  | Operation          | Name                  | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |                       |  1912K|    56M|       | 21466   (3)| 00:04:18 |
    |   1 |  SORT GROUP BY     |                       |  1912K|    56M|   161M| 21466   (3)| 00:04:18 |
    |   2 |   TABLE ACCESS FULL| CREDIT_CARD_PYMT_DTLS |  1912K|    56M|       |  4863   (3)| 00:00:59 |
    ----------------------------------------------------------------------------------------------------
    
    9 rows selected.
    
    SQL> select index_name,index_type
      2  from all_indexes
      3  where table_name = 'CREDIT_CARD_PYMT_DTLS';
    
    INDEX_NAME                     INDEX_TYPE
    ------------------------------ --------------------
    INDX_TRANTYPE                  BITMAP
    INDX_PCARD                     NORMAL
    INDX_PSTATEMENT_DATE           NORMAL
    The query uses all records in the CREDIT_CARD_PYMT_DTLS table. Transaction type will be either 'C' or '.

    CREDIT_CARD_PYMT_DTLS has 2 million lines and the qury will display 1.5 million lines. Table statisticas are up to date.

    The query takes now almost 5 minutes. Y thaere a way to reduce the time?

    Our DB server has 8 processors and 8 GB of memory. Is it authentic?

    Thanks in advance.

    Published by: user11115924 on April 29, 2009 02:43
    All columns used in the query are already indexed. (Of course, not only for this query.)

    I should not get too hung up the full Table Scan necessarily - Oracle makes a decision, and even with your new index, he still thinks it is the most effective way to recover the data.

    Did you collect statistics on this new index?

    You have created the index with:

    TO_CHAR("STATEMENT_DATE",'MON-RRRR')
    

    Yet, you seem to be just by selecting statement_date in your query: Oracle cannot use the index (according to functions) in this case!

    If you have only a small number of columns in this table, you can consider an Table of Index organized (ITO), then the table itself is a clue.

    I'd be more inclined to optimize the complete analysis of the table and the creation of other clues, I would say, have you tried the PARALLEL tip?

  • Transient attribute based on the selected query by using a function call

    Hello

    Post version is 11.1.1.7.0 JDeveloper.

    I'm not able to get the following work properly;

    1. I have a scenario header / detail.
    2. Calculate a value for each row returned detail that I find. This calculation is done using an existing database to function.
    3. The function requires 3 input parameters.
    4. Two of these parameters can be retrieved in the detail row and one is a value which is on the header.
    5. I created a transient attribute on the object of the detail view and selected the following properties of the 2 attribute;
      1. Mapped to the column or SQL
      2. Selected in SQL
    6. I entered the following SQL Expression;
      1. function_name (DetailTableAlias.value1, DetailTableAlias.value2, ViewLinkName.value3)
    7. Running AOS that contains the objects of view header / detail, I encounter a SQL error which indicates that ViewLinkName.value3 is an invalid identifier.
      1. I can understand why this error occurs.
    8. If I change the ViewLinkName.value3 to a literal value, the error will not occur.

    So, my question is how can I pass the third parameter to the transitional attribute database function call as the value literal and not as a reference to one, missing attachments header table, column?

    Concerning

    Leon.

    Hi Leon

    Have you explored solve this by an inline SQL query to derive the 3rd parameter of the function? In other words, the problem in SQL instead of ADF.

    DMI

  • as with the select query

    Hello

    I have a query something like...

    Select...

    ....

    where

    b.ProdName as 'GEAR of the TREE %' or b.prodname like '% FRONT GEAR %' or b.prodname like '% BREAK 4 %k '.

    and

    b.ProdName as

    (select the name of the society of companyms

    where < some comdition >

    )

    order of 3.6

    I have blocked in:

    b.ProdName as

    (select the name of the society of companyms

    where < some comdition >

    )

    How to give a select query with like operator.

    In above query I want to b.prodname as above and the name of the company for which I give condition.  Company names are stored in another table and I want to select and use them with like operator.

    Thank you.

    Hello

    It is not clear what you want to do.

    One possibility is an EXISTS subquery, like this:

    ...

    WHERE (b.prodname LIKE "% of the CYCLE of the TREE" - begins with this text

    OR b.prodname LIKE '% FRONT GEAR %' - contains this text

    OR b.prodname LIKE '% BREAK 4 %k' - contains this text

    )

    AND THERE ARE)

    SELECT 1

    OF companynms

    WHERE--a condition

    AND b.prodname AS business

    )

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • How to write a simple select query to get the data of the table as an XML.

    How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
    select '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' 
    from temp_table where id_num BETWEEN 1 AND 10;
    I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select query
    without using XMLGEN, XMLQUERY or any other packages built and function?

    I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.

    What is wrong with him?

    At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
    In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:

    SQL> create or replace function my_url_escape (url in varchar2)
      2  return varchar2
      3  deterministic
      4  is
      5  begin
      6   return utl_url.escape(url, false, 'AL32UTF8');
      7  end;
      8  /
    
    Function created
    
    SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual;
    
    MY_URL_ESCAPE('HTTP://SOME.URI
    --------------------------------------------------------------------------------
    http://some.uri.com/param?lang=fr&text=contr%C3%B4le
     
    
  • SELECT query using ormExecuteQuery()

    I'm doing a SELECT query by using ormExecuteQuery().  Here is the code I have:

    Categories = ormExecuteQuery("from Category where Id IN (?)",[CategoryList]);

    It works only when there is the 1 value in the CategoryList.  either it works:

    Categories = ormExecuteQuery("from Category where Id IN (?)",[9]);

    This work IS NOT:

    Categories = ormExecuteQuery("from Category where Id IN (?)",[8,9,10]);

    Help would be greatly appreciated.

    It works:

    Categories = ormExecuteQuery("from Category where Id IN (:IdList)",{IdList=ListToArray(CategoryList)});

    Looks like it would be too much, but it does not work.

    Categories = ormExecuteQuery("from Category where Id IN (?)",[ListToArray(CategoryList)]);

  • Select the query with the level line list where the clause

    Hi all

    I am creating a tabular presentation based on a SQL query that has a list of selection based on a query with a where clause clause that refers to a column in the original SQL query.

    The situation is, I have a table that stores the client_id, source_id, and build_id, lets call it client_source. I have a second table, build_source, containing source_id and build_id, one to many relations between the two (1 source_id could have build_id 1-7).

    Using a tabular presentation, I want to select the correspondent build_id to use in client_source, but the selection list should contain only the build_id for this particular source_id of lines.

    Here is an example of the SQL source of tabular presentation;

    Select
    s.ROWID,
    s.CLIENT_ID,
    s.SOURCE_ID,
    APEX_ITEM. SELECT_LIST_FROM_QUERY (1, s.BUILD_ID,)
    "Select display b.build_id, b.build_id return.
    b build_source where b.source_id = s.SOURCE_ID ') lst
    of s client_source

    what I want to achieve, it's as source_id "BOLD" match fields. When the query is built this way, I get an error of "invalid identifier" Oracle on s.SOURCE_ID during execution.

    Is there some special tags to be used to refer to the external column? I must be missing something because this looks like a pretty mundane problem.

    I am running on 4.1.0.00.32, on an Oracle 10 g release 10.2.0.4.0 Server Express request.


    I look forward to useful responses!


    See you soon,.
    Jason

    Published by: 1005131 on May 9, 2013 19:02

    Your selection by query list receives a static SQL. That SQL can't "see" the value of your s.source_id.
    But it would work like this:
    where b.source_id = ' | s.SOURCE_ID)

    You would be the value for the SQL concatenation. It is not ideal, but it will work.

    Jorge

  • Please send me selection for the following query statement...

    FOR I IN 1.9 LOOP
    IF shift (i) IS NULL THEN
    FOR y IN i + 1.9 LOOP
    IF shift (y) IS NOT NULL THEN
    (I) shift: shift = (y);
    Shift (y): = NULL;
    EXIT;
    END IF;
    END LOOP;
    END IF;
    END LOOP;



    Please how to write the select query to replace the lines of code above

    Please proceed here complete and this code did SHIFT here.

  • 'Function SQL Query return' using with Flash graphics

    I created a pl/sql function that returns a SQL query in a varchar2 of this form:

    Select the null link
    -value > < x value
    < value y of Series1 > series 1 label
    < value Series2 y > 2 series label
    < value of y Series3 > series 3 Label
    ...
    ...
    from tablea a
    Join tableb b
    On a.col = b.col
    order of < x value >

    If I call the function of a graphic Flash box series SQL with the Type of Source query "SQL query" value that returns the function like this:

    return functionname (to_date ('30-sep-2010, ' mon-dd-yyyy ""))

    It parses correctly and the page is saved; However, when I run the page I get no output - error messages or another indication of a problem.

    Now, if I call the function in a SQL client, capture the result of the query SQL using the dbms_output and paste that into the box graphic Flash series SQL - change the Source Type of SQL query query - and save the page it works fine when I run it and returns a chart series flash.

    Can anyone suggest either;

    1. what I might have missed or done wrong?
    2. a way to effectively diagnose the problem...

    I tried to use the debugger Apex - what is very nice, indeed - but it provides no information on what might be my problem. I tried to write my own my function debug messages using the apex_debug_message package - nothing...

    Thank you
    Eric

    Hi Eric,.

    Try to pull the source like this:

    begin
       return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'));
    end;
    

    This works very well for me, and if I take the begin-end and the final semicolon from the return statement I get the same behavior as you.

    He doesn't mention in aid of the source (only during the wizard if) this source type must be expressed in this way, but I agree, it would be useful that the tool would validate to this format meets it "Query SQL that returns the function" or give some sort of indication of the sentence. In any case, this should help you will again.

    Hope this helps,
    John

    If you find this information useful, please do not forget to mark the 'useful' or 'correct' post so that others benefit as well.

  • place a select query calculation in a different column in the same table

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my column "percent" on my table of dgpercentagedatachart vacuum.

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    Hello

    2685870 wrote:

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my empty column '%' on my table of dgpercentagedatachart .

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    To change an existing column in a table, you can use the UPDATE or MERGE, instructions like this:

    UPDATE dgpercentagedatachart

    Percentage of VALUE = 100,00 * totalcecrating

    / lowestfeederrating

    ;

    Noramlly, tables is not redundant columns like this.  If percent can always be calculated from other columns, then it is probably better to calculate at run time and store it in the database, where you will have to be updated each time the columns it depends on change.  You can use a view to avoid having to encode them the calculation.

    If you really don't want a column that can be calculated in the same lines other columns, then use a virtual column (if you use Oracle 11 or higher).

    I hope that answers your question.

    If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.

    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • help me out with a query with an output that has own text.

    help me out with a query with an output that has own text.

    For example select name from tbl_name

    Ben "is my name"-> should be the output

    Hello

    3cc59f7b-B8C1-4EFA-8385-e0d8720a689c wrote:

    help me out with a query with an output that has own text.

    For example select name from tbl_name

    Ben "is my name"---> should be the output

    Sorry, it is not clear what you want.

    If the table contains only "Ben", then you can get the output above using a query like this:

    SELECT name. '' my name is' ' AS name_plus

    FROM tbl_name;

    I hope that answers your question.

    If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • Error in the SELECT query

    Hello

    Oracle version: 11g R2 (11.2.0.2)

    I get the following error message (I'm using TOAD for Oracle last version 12.1):

    ORA-12801: error reported in the parallel query P032 Server

    ORA-01114: block write IO file error (block #)

    ORA-01114: IO error to the file 201 (block # 2165248) writing block

    ORA-27072: IO file error

    Linux-x86_64 error: 28: no space is available on the device

    Additional information: 4

    When you run a SELECT query:

    SELECT field1, Field2...

    OF (REVENUE_SOURCE b

    INNER JOIN ACCOUNTS_CLASSIFICATION one

    WE b.SUB_ACCOUNT = a.SUB_ACCOUNT)

    INNER JOIN REPORT_PRODUCT_ID c

    ON b.REPORT_PRODUCT_ID = c.REPORT_PRODUCT_ID

    WHERE a.UC_BUSINESS_UNIT = 'ANX.

    AND b.report_mm > =.

    (SELECT ADD_MONTHS (MAX (report_mm),-13))

    OF REVENUE_SOURCE)

    AND b.REVENUE_FLAG = - 1

    AND (b.CALLS <>0 b.MINUTES <>0 b.CHARGE_AMOUNT GOLD <>GOLD 0);

    Please notify.

    NOTE: the query worked well for a while, no errors, then all suddenly it became much accentsr and then I started to get the error message above.

    Kind regards

    M.R.

    Hello

    ORA-27072: IO file error

    Linux-x86_64 error: 28: no space is available on the device

    Looks like a system or OS, no SQL or PL/SQL problem problem.  I think you will answer sooner if you check this issue as 'Response' and start a new question in the forum of "General Question":

    https://forums.Oracle.com/community/Developer/English/oracle_database/general_questions/content

    My guess is that Oracle tries to allocate space in the tablespace temp, but cannot because the disk is full.  If you have a full disk, then create the space to this topic.

    I see nothing wrong with your code; Certainly, nothing which would cause an error like that.  The fact that the query has worked well for some time confirms that there is noting wrong with the request itself; It is just triggering a mistake elsewhere.

  • Please, help me to query SQL Construct.


    Hi Experts,

    Could you please help me to query SQL Construct.  Please find the details

    HOSTNAME HOSTTYPE DEM R1 R2
    RS123 P ABC 24.5 265,5

    RS123 P CYC 24.5 265,5

    RS123 P ADDS 24.5 265,5

    RS123 P ADE 24.5 265,5

    RS123 P SRC 24.5 265,5

    EXPECTED RESULTS

    HOSTNAME      HOSTTYPE                              MNE                                                                      R1          R2
    RS123 P ABC, CYC, ADD, ADE, CBC 24.5 265,5

    Concerning

    See you soon

    with t as)

    Select "RS123' hostname 'P' hosttype, 'ABC' dem, 24.5 r1, r2 265,5 Union double all the

    Select 'RS123', 'P', "CYC", 24.5, 265,5 double Union all

    Select 'RS123', 'P', 'ADD', 24.5, 265,5 double Union all

    Select "RS123', 'P', 'ADE', 24.5, 265,5 double Union all

    Select 'RS123', 'P', 'SRC', 24.5, 265,5 double

    )

    Select the host name,

    HostType,

    RTrim (XMLAGG (XmlElement(e,MNE,','). (Extract ('//Text ()')), ',') DEM,.

    R1,

    R2

    t

    Group hostname,

    HostType,

    R1,

    R2

    /

    HOSTN H DEM R1 R2
    ----- - -------------------- ---------- ----------
    RS123 P ABC, CBC, ADE, ADD, CYC 24.5 265,5

    SQL >

    SY.

  • Error exporting in the level of query with several conditions

    When I run the following query to export with the result.



    C:\Documents and Settings\ITL > exp scott/tiger@orcl tables = (emp) QUERY = "" WHERE deptno > 10 and sal! 2850 = "' LOG = log011.log FILE = exp.dmp"

    Export: Release 10.2.0.1.0 - Production on Wed Jan 30 10:01:27 2013

    Copyright (c) 1982, 2005, Oracle. All rights reserved.


    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With partitioning, OLAP and Data Mining options
    Export performed WE8MSWIN1252 and AL16UTF16 NCHAR character set

    About to export specified tables by conventional means...
    . . export the rows in the table EMP 10 exported
    EXP-00091: exporting more than questionable statistics.
    EXP-00091: exporting more than questionable statistics.
    Export completed successfully with warnings.



    But when I run it with the following condition, then it displays the following error...




    C:\Documents and Settings\ITL > exp scott/tiger@orcl tables = (emp) QUERY ='"WHERE deptno > 10 and work!" = 'CLERK' ' ' LOG = log011.log FILE = Exp01.dmp.
    LRM-00111: no closing quote for value 'LOG = log01'

    EXP-00019: failure of the treatment of parameters, type 'HELP EXP = Y' help
    EXP-00000: export completed unsuccessfully


    C:\Documents and Settings\ITL > exp scott/tiger@orcl tables = (emp) QUERY = "WHERE deptno > 10 and work! = 'CLERK' ' LOG = log5.log FILE = exp01.dmp
    LRM-00112: multiple values not allowed for the parameter "query".

    EXP-00019: failure of the treatment of parameters, type 'HELP EXP = Y' help
    EXP-00000: export completed unsuccessfully


    Please suggest a solution for this.

    Hello

    Single quotes used for CLERKS are very probably the origin of the problem.
    C:\Documents and Settings\ITL > exp scott/tiger@orcl tables = (emp) QUERY ='"WHERE deptno 10 > and job!" = 'CLERK' ' ' LOG = log011.log FILE = Exp01.dmp.

    try to replace this
    C:\Documents and Settings\ITL > exp scott/tiger@orcl tables = (emp) QUERY ='"WHERE deptno 10 > and job!" = "REGISTRAR" "' LOG = log011.log FILE = Exp01.dmp.

    Two single quotes (no quotes) to place an apostrophe for CLERK.

    Thank you
    Padma...

Maybe you are looking for