Problem using alias field names in a sql query

Hello,
I have a question regarding a simple Oracle database SQL query writeup:
In the following (badly written but properly working) SQL query:
Query 1:
select
soe.field1,
(soe.field2 + soe.field3) as field4,
(soe.field5 - (soe.field2 + soe.field3)) as field6,
(select comp.parValue*soe.field7
from
CompTable comp) as parValue,
(select soe.field8 - (comp.parValue*soe.field7+ soe.field9)
from
CompTable comp) as field10
from
SomeTable soe
PROBLEM 1:
I am re writing the code (soe.field2 + soe.field3) to get the alias field4 or column name field4 that I have created on the fly in the previously for use with the following fields. Can't I rewrite the query as follows. There is something simple missing!
Query 2:
select
soe.field1,
(soe.field2 + soe.field3) as field4,
soe.field5 - field4 as field6, <<< field4 does not work here
(select
comp.parValue*soe.field7
from
CompTable comp) as parValue,
(select
soe.field8 - (comp.parValue*soe.field7+ soe.field9)
from
CompTable comp) as field10
from
SomeTable soe
PROBLEM 2:
Similar to the above problem, I was thinking to get a field parValue out of the CompTable table and re-use many times rather than the code shown in Query 1:
Query 3:
select
soe.field1,
(soe.field2 + soe.field3) as field4,
soe.field5 - field4 as field6,
soe.field7* (select comp.parValue from CompTable comp) as parValue1,
soe.field8 - (parValue1*soe.field7+ soe.field9) as field10      <<<< parvalue1 does not work here
parValue1*soe.field9 as TaxCondition               <<<< parvalue1 does not work here
from
SomeTable soe
See that the query becomes so simple, but the above query does not work. There is something fundamentally wrong in my usage of the alias field names in creating other fields. The Query1 seems to be the only working option but its very slow as I am redoing and re-writing the whole code again and again to get the parValue field out of the CompTable table for use to create many other fields.
I will appreciate if you can guide me in the right direction on this issue.
Thanks and Regards
Rama

SELECT tmp.contract_no, tmp.Actual, tmp.Actual - tmp.NbHours
FROM ( SELECT t.contract_no, sum(l.hrs) AS Actual, (c.labour_hours * c.labour_progress_per) / 100 AS NbHours
FROM TASK_DELEGATION t
INNER JOIN COST_CODE c
ON t.cost_code = c.cost_code AND t.contract_no = c.contract_no AND t.is_inactive=0
INNER JOIN Labour.dbo.LABOURALLOT l
ON l.contractNo = c.contract_no AND l.costcode = c.cost_code AND l.pm = 'N'
GROUP BY t.contract_no, c.labour_hours, c.labour_progress_per
) tmp

Similar Messages

  • Prepared statement problem using a field name that contains a "?"

    I am attempting to execute the following query via use of a PreparedStatement:
    select [Spread_By_Cost_Center?], Debit_Category, Credit_Category, Start_Date, End_Date, Allocation_Type From ALLOCATION_FORMULA Where FormulaID = ?
    The query fails with the following message:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT
    field incorrect
    However, I can run this query directly in MS-ACCESS, using a value for the substitution parameter (i.e., FormulaID = 1)
    If I remove the "Spread_By_Cost_Center? field from the query within the PreparedStatement, the PreparedStatement query executes successfully.
    So, it would appear that the "?" in the field name is possibly being treated as a substitution parameter. Is this a bug within PreparedStatement? I do not want to use a Statement object, as the PreparedStatement provides a much more elegant solution (when it works).
    Any suggestions?

    That may be so, but as I see it there are two alternatives:
    1. Wait for the "bug" to be fixed.
    2. Change the database to use less problematic column names.
    I know which alternative I would choose.

  • Alias with field name in MS SQL Server

    Is it possible that we can define alias for field name in MS SQL Server?
    For example:
    mytable : Id, Name, Value
    Could we define "AnotherName" for "Name" field that we can call it from sql
    SELECT anothername from mytable

    I don't know if you can "permanently" create an alias
    without a view or something like that but if you just
    want another name when you execute a select do this:
    Select name as another name from tableAt least in some databases the syntax for that can vary slightly. So the following might be needed....
    Select name as 'another name' from table

  • How to get error's field name when execute sql error

    I want to get the error's field name when execute sql error,but SQLException is not provide corresponding function to get it.
    How can I do for it?

    user523110,
    I believe the "unique constraint" error message displays the name of the constraint, not the column name, as you have posted.
    As far as I know, the only way to extract the column(s) would be to query the data dictionary using the constraint name provided in the error message.
    Also, as far as I know, there is nothing in the JDBC API that can return the names of the columns associated with a given unique constraint.
    Good Luck,
    Avi.

  • Field value retrieve from sql query

    Hi,
    Is there any way to code sql query into form field in rtf template ?.
    I have converted an oracle report to BI publisher (e-business suite R12) but I have a form field that contain a sql query that retrieve a value from database. I don't know how to code sql query in form field in rtf template.
    Thanks for help,

    http://winrichman.blogspot.com/search/label/cross%20tab
    http://winrichman.blogspot.com/search/label/Cross-tab
    http://winrichman.blogspot.com/search/label/Dynamic%20column

  • Using SQL alias column names in same SQL

    Hi,
    I am converting some Teradata SQL queries and these queries have the ability to use column defined aliases within the same query, something like :
    SQL> select 'test' as alias1, 'test2' as alias2, alias1 from dual
    Does anyone know how I can get Oracle to do this ????
    Many thanks
    Ben

    Hi,
    Yes I did think of that - its just the queries calculated columns are quite large - sample below show a value calculated currently based on alias names - just trying to find an easier way to apply.
    I was hoping for some magical syntax that has eluded me !
    Ben
    (exp(case when (constant_contrib + fsnumber_contrib + herolevel_contrib + is_colmans_contrib + is_heinz_contrib + is_short_life1_contrib + is_short_life2_contrib + is_short_life3_contrib + logcount_prod_contrib + offer_shelf_cap_contrib + promointensity_contrib + std_shelf_cap_contrib + xforprice_add_1_contrib + ( (power(sh_ms_variables.xfspr,1)) * formula_coefficients.coeff_xfspr1 ) + ( (power(sh_ms_variables.xfspr,2)) * formula_coefficients.coeff_xfspr2 ) + ( (power(sh_ms_variables.xfspr,3)) * formula_coefficients.coeff_xfspr3 ) + ( (power(sh_ms_variables.xfspr,4)) * formula_coefficients.coeff_xfspr4 ) + ( sh_ntnl_variables.xnfor2 * formula_coefficients.coeff_xnfor2 ) + ( sh_ms_variables.xnforfs1 * formula_coefficients.coeff_xnforfs1 ) + ( sh_ms_variables.xnforfs2 * formula_coefficients.coeff_xnforfs2 ) + ( sh_ms_variables.xnforfspl * formula_coefficients.coeff_xnforfspl ) + ( sh_ntnl_variables.xnforpl * formula_coefficients.coeff_xnforpl ) + ( (power(sh_ms_variables.xpr,1)) * formula_coefficients.coeff_xpr1 ) + ( (power(sh_ms_variables.xpr,2)) * formula_coefficients.coeff_xpr2 ) + ( (power(sh_ms_variables.xpr,3)) * formula_coefficients.coeff_xpr3 ) + ( (power(sh_ms_variables.xpr,4)) * formula_coefficients.coeff_xpr4 )) < 500 then (constant_contrib + fsnumber_contrib + herolevel_contrib + is_colmans_contrib + is_heinz_contrib + is_short_life1_contrib + is_short_life2_contrib + is_short_life3_contrib + logcount_prod_contrib + offer_shelf_cap_contrib + promointensity_contrib + std_shelf_cap_contrib + xforprice_add_1_contrib + ( (power(sh_ms_variables.xfspr,1)) * formula_coefficients.coeff_xfspr1 ) + ( (power(sh_ms_variables.xfspr,2)) * formula_coefficients.coeff_xfspr2 ) + ( (power(sh_ms_variables.xfspr,3)) * formula_coefficients.coeff_xfspr3 ) + ( (power(sh_ms_variables.xfspr,4)) * formula_coefficients.coeff_xfspr4 ) + ( sh_ntnl_variables.xnfor2 * formula_coefficients.coeff_xnfor2 ) + ( sh_ms_variables.xnforfs1 * formula_coefficients.coeff_xnforfs1 ) + ( sh_ms_variables.xnforfs2 * formula_coefficients.coeff_xnforfs2 ) + ( sh_ms_variables.xnforfspl * formula_coefficients.coeff_xnforfspl ) + ( sh_ntnl_variables.xnforpl * formula_coefficients.coeff_xnforpl ) + ( (power(sh_ms_variables.xpr,1)) * formula_coefficients.coeff_xpr1 ) + ( (power(sh_ms_variables.xpr,2)) * formula_coefficients.coeff_xpr2 ) + ( (power(sh_ms_variables.xpr,3)) * formula_coefficients.coeff_xpr3 ) + ( (power(sh_ms_variables.xpr,4)) * formula_coefficients.coeff_xpr4 )) else 500 end ) - 1) AS uplift,
    Edited by: user485052 on Dec 10, 2010 3:08 AM

  • Problem with column/field names in Oracle resultset being UPPERCASE

    Hi everyone,
    I understand that Oracle DBMS returns all the field names in UPPERCASE in the result set. However this is undesired for my application and I was wondering if there is any workaround for getting the field names in the application in exactly the same format as your select query. Is there any set method which can be called before to control this behavior.
    E.g. select ename as employeename from table_name;
    ORACLE RETURNS --> EMPLOYEENAME
    Required --> employeename
    Please help me
    ..Vinit

    Vinit,
    You can use column aliases in your query -- see Oracle SQL Reference for more details.
    Then you can set some connection property in Oracle JDBC that allows you to obtain the column alias (I think). Check the Oracle JDBC User's Guide and Reference for more details.
    Good Luck,
    Avi.

  • How to use get column name.vi in SQL toolkit 2.0?

    Due to the vi "get column name.vi" paremeters,no table name has connected to the vi. So, I want to ask how to use this vi for gain one column name of a table. Maybe there are some other ways to solve column name getting.
    Thanks.

    Thanks!
    Error 4101 Description:
    Execute SQL - The connection, statement, or query handle you provided is not valid.
    I don't just used the toolkit in a while,now, I am developing a irrigation system. For the table field names defined by users,column names must be known before any select operations. Do you have any other good idea about drawing out the columnname parameters?
    As you know, a valid DSN and table have been also available. The database I used is Access. The bad thing to me is that there is no any text information gotten. And I think, it may be some problems in connection way which I don't find out.
    Really appreciated by your reply.
    Could you give me some example in the aspect?
    Thank you again.

  • Alias a field name in a join query

    I have a database with spaces in the field names (not my fault).
    I am having a problem with the query because one of the fileds I am joining on has a space in its name. See bolded text.
    SELECT *
    FROM employee_passwords
    INNER JOIN employee_general_info
    ON employee_passwords.Employee_ID=employees.[Employee ID]
    WHERE username = '#username#' AND password = '#password#'  
    So I get this error message
    Error Executing Database Query.
    [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name 'employees.Employee ID'.
    Is there a way to alias the employees.[Employee ID] field?

    Should be
    ON employee_passwords.Employee_ID=employee_general_info.[Employee ID]

  • Php select using column Field names ?

    Hello,
    I need some advice using this select
    usually I do this
    $query = "SELECT * FROM table WHERE title LIKE 'body'";
    it works, is fast and no problems.
    But now I've a big table [id, ..., ...] and need to select just the row starting with body, so I use body%
    question is
    How can I select records using the Field property of the MySql table? (Field, Type, Collation, Attributes,...)
    I want something like
    $query = "SELECT * FROM table WHERE FIELD LIKE 'body_%'";
    Thanks
    Pluda

    ExPluda wrote:
     ok, I know the name of my table, but don´t know the name of the fields, or I know them, but need this to be dinamic, so what i´m trying is to select all content from table 'body' where FIELD name like ´body%'
    I understand what you're trying to do (or at least I think I do). The answer is simple. You can't do it.
    Why not? Because it's nonsense. If you know the name of the table, you know the names of the fields (columns). Moreover, the WHERE clause is used for checking values in fields, not for checking field (column) names.
    What you're actually trying to do is probably this:
    SELECT [field_name] FROM body.
    By the way, this sort of question should really be posted in the Application Development forum.

  • Problem in key field name in FCC

    hi,
    I am using FCC on the sender side.
    Source file is
    1;;PY;X101;20060630;06;20060630;GBP;Ref.1;Payroll June 2006; (Header)
    1;1;40;S2225000;;1050;;;;;;;;;;;;;;;X101003;;;;;;;;;;;;;;;
    1;2;240;S2225000;;4563;;;;;;;;;;;;;;;X101004;;;;;;;;;;;;;;;
    1;3;31;3100001;;5013;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1;4;31;3100002;;600;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    2;;PY;X101;20060630;06;20060630;GBP;Ref.2;Payroll June 2006;  (Header)
    2;1;40;S2225000;;530;;;;;;;;;;;;;;;X101003;;;;;;;;;;;;;;;
    2;2;40;S2225000;;2490;;;;;;;;;;;;;;;X101004;;;;;;;;;;;;;;;
    2;3;31;3100002;;3020;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    The first field in the header is the key field to identify the header, which keeps incrementing for evry occurence of the header.
    So for the first occurence of the header first field of header will be 1, first field of item will be 1( same as header) and second field of item will be the key field now  which will increment with evry occurence of item within the header.So there is no constant value for key field name.
    So how do i perform FCC for this type of structure?
    Regards,
    Loveena

    Hi,
    You can create a custom Adapater Module and add it in your Sender Adapter. This will add a Unique Identifier to your Header and Record item which you can give in FCC.
    For more details refer to this forum
    https://forums.sdn.sap.com/click.jspa?searchID=-1&messageID=6143385
    Thanks
    Amit

  • JPA Problem using alias for columns in a query

    Hello, I am having some problems with a query that I am trying to use in my JEE project. This query doesnt return an entity but a group of values. I created a class representing the result and a query with the jpa constructor expression but it is not working.
    The problem is that in the query I added some alias to the results, and when I try to run the project it says that it cannot parse the query.
    My Query:
    Query query = em.createQuery("SELECT NEW vo.VOOperacionesAgrupadas (o.nemotecnico as nemotecnico, o.esCompra as esCompra, i.equivUltimo as equivUltimo, sum(o.saldo) as saldo, sum(o.utilidad) as utilidad, sum(o.tasaCompraVenta)/count(o.nemotecnico) as promedioTasaCompra, (i.equivUltimo-sum(o.tasaCompraVenta)/count(o.nemotecnico))*100 as puntosBasicos) FROM Operaciones o, Instrumentos i WHERE o.idUsuario = :idUsuario AND o.nemotecnico = i.nemotecnico AND o.estaCerrada = 'false' Group by o.nemotecnico, o.esCompra, i.equivUltimo"); When I use that the server returns :
    Exception Description: Syntax error parsing the query [SELECT NEW vo.VOOperacionesAgrupadas (o.nemotecnico as nemotecnico, o.esCompra as esCompra, i.equivUltimo as equivUltimo, sum(o.saldo) as saldo, sum(o.utilidad) as utilidad, sum(o.tasaCompraVenta)/count(o.nemotecnico) as promedioTasaCompra, (i.equivUltimo-sum(o.tasaCompraVenta)/count(o.nemotecnico))*100 as puntosBasicos) FROM Operaciones o, Instrumentos i WHERE o.idUsuario = :idUsuario AND o.nemotecnico = i.nemotecnico AND o.estaCerrada = 'false' Group by o.nemotecnico, o.esCompra, i.equivUltimo], line 1, column 53: syntax error at [as].
    Internal Exception: MismatchedTokenException(8!=82)
    GRAVE: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
    Exception Description: Syntax error parsing the query [SELECT NEW vo.VOOperacionesAgrupadas (o.nemotecnico as nemotecnico, o.esCompra as esCompra, i.equivUltimo as equivUltimo, sum(o.saldo) as saldo, sum(o.utilidad) as utilidad, sum(o.tasaCompraVenta)/count(o.nemotecnico) as promedioTasaCompra, (i.equivUltimo-sum(o.tasaCompraVenta)/count(o.nemotecnico))*100 as puntosBasicos) FROM Operaciones o, Instrumentos i WHERE o.idUsuario = :idUsuario AND o.nemotecnico = i.nemotecnico AND o.estaCerrada = 'false' Group by o.nemotecnico, o.esCompra, i.equivUltimo], line 1, column 53: syntax error at [as].
    Internal Exception: MismatchedTokenException(8!=82)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: Exception [EclipseLink-8024] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.JPQLException
    Exception Description: Syntax error parsing the query [SELECT NEW vo.VOOperacionesAgrupadas (o.nemotecnico as nemotecnico, o.esCompra as esCompra, i.equivUltimo as equivUltimo, sum(o.saldo) as saldo, sum(o.utilidad) as utilidad, sum(o.tasaCompraVenta)/count(o.nemotecnico) as promedioTasaCompra, (i.equivUltimo-sum(o.tasaCompraVenta)/count(o.nemotecnico))*100 as puntosBasicos) FROM Operaciones o, Instrumentos i WHERE o.idUsuario = :idUsuario AND o.nemotecnico = i.nemotecnico AND o.estaCerrada = 'false' Group by o.nemotecnico, o.esCompra, i.equivUltimo], line 1, column 53: syntax error at [as].
    Internal Exception: MismatchedTokenException(8!=82)
    at org.eclipse.persistence.exceptions.JPQLException.syntaxErrorAt(JPQLException.java:362)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.handleRecognitionException(JPQLParser.java:304)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.addError(JPQLParser.java:245)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.reportError(JPQLParser.java:362)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.recoverFromMismatchedElement(Unknown Source)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(Unknown Source)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.mismatch(Unknown Source)
    at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.match(Unknown Source)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.constructorExpression(JPQLParser.java:2635)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectExpression(JPQLParser.java:2045)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectItem(JPQLParser.java:1351)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectClause(JPQLParser.java:1266)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectStatement(JPQLParser.java:352)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.document(JPQLParser.java:276)
    at org.eclipse.persist
    GRAVE: ence.internal.jpa.parsing.jpql.JPQLParser.parse(JPQLParser.java:133)
    at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.buildParseTree(JPQLParser.java:94)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:198)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:173)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:125)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:109)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1326)
    ... 59 more
    Caused by: MismatchedTokenException(8!=82)
    ... 74 more
    What can I do?? I have been stuck in this problem for 2 weeks :s I have tried almost everything..
    Thanks in advance for your help!

    SELECT tmp.contract_no, tmp.Actual, tmp.Actual - tmp.NbHours
    FROM ( SELECT t.contract_no, sum(l.hrs) AS Actual, (c.labour_hours * c.labour_progress_per) / 100 AS NbHours
    FROM TASK_DELEGATION t
    INNER JOIN COST_CODE c
    ON t.cost_code = c.cost_code AND t.contract_no = c.contract_no AND t.is_inactive=0
    INNER JOIN Labour.dbo.LABOURALLOT l
    ON l.contractNo = c.contract_no AND l.costcode = c.cost_code AND l.pm = 'N'
    GROUP BY t.contract_no, c.labour_hours, c.labour_progress_per
    ) tmp

  • Using table field name as a variable

    Hi ,
    Is it possible to map some values to a field in a Ztable , if I have the field name of the Ztable in a variable.
    For ex:
    I have a ZTABLE -- which has some fields - ZF1 and ZF2.
    In my code, I determine the field in which I want to put data at runtime. For ex, in my code i determine at runtime I want to update field ZF2 , but I have this field name in a variable <V_FIELDNAME>
    So, Is it possible to do something as:
    <V_FIELDNAME> = ZF2.
    ZTABLE-<V_FIELDNAME>    =    <VARIABLE -SOME VALUE>.
    and this value should actually maps to ZTABLE-ZF2.
    If it is possible , how to do it ?
    Thanks-

    Hi Tamas,
    Thanks a lot for ur post ! it did certainly help. However, I need some more help.
    Here is what I need -
    I will have a string coming up from an interface which would be something like : Val1;Val2;Val3
    And in SAP R/3 I have a variable maintained as : Field1;Field2;Field3
    Field1 Field2 and Field3 are fields of a ZTABLE.
    So , at runtime, using the variable I have to determine which Value goes to which field and then insert this field in ZTABLE.
    So, ultimately , code should perform the following actions:
    ZTABLE-FIELD1 = Val1
    ZTABLE-FIELD2 = Val2
    ZTABLE-FIELD3 = Val3
    Insert ZTABLE.
    Going by code you provided, I can assign individual values, But then ultimately I need to map it to a structure which can be used to insert in a DB table. How can I do this?
    Thanks-

  • Can I use a field name in text module

    Hi,
    I get a object name of the standard text in a field.  Can I use that field in Text module.
    Thanks,
    Srinivas.

    Go to t-code SMARTFORMS->Text Module->Create or Edit-> choose add icon and type your field name (used in your smartform) like this &fieldname&, then use this Text module in your smartform.

  • Resolve column names in a sql Query

    Hi Folks,
         I’m upgrading an application and there are database columns that have major changes that could affect production reports. I would like to survey v$SQL for a few days to see if these columns are affected. Here’s the problem.
    Looking at a SQL query to determine which columns are used is not nearly as easy as it sounds. Are there any oracle functions or 3rd party tools that can be used to list the columns used by a sql query? (this gets extremely tricky when subqueries become involved)
    For instance.
    select
    name, b.dep_id, employee_id
    From emp a
    Inner join v_department b on a.dep_id=b.dep_id
    Columns used:+
    Emp.name+
    Departments.dep_id (under the view)+
    Emp.employee_id+
    Emp.dep_id (from the join)+

    If you're on > 10g, you can use dbms_xplan with "all" option.
    It shows "column projection information" which is exactly what you want.
    UKJA@ukja102> set serveroutput on
    UKJA@ukja102>
    UKJA@ukja102> drop table t1 purge;
    Table dropped.
    Elapsed: 00:00:00.03
    UKJA@ukja102> create table t1(c1 int, c2 int);
    Table created.
    Elapsed: 00:00:00.03
    UKJA@ukja102>
    UKJA@ukja102> explain plan for
      2  select
      3    t1.c1, t1.c2, v.cnt
      4  from t1,
      5    (select /*+ no_merge */ c1, count(*) as cnt
      6        from t1
      7        group by c1) v
      8  where
      9    t1.c1 = v.c1
    10  ;
    Explained.
    Elapsed: 00:00:00.01
    UKJA@ukja102>
    UKJA@ukja102> @plan_all
    UKJA@ukja102> select * from table(dbms_xplan.display(null,null,'all'))
      2  /
    PLAN_TABLE_OUTPUT                                                              
    Plan hash value: 536125944                                                     
    | Id  | Operation            | Name | Rows  | Bytes | Cost (%CPU)| Time     |  
    |   0 | SELECT STATEMENT     |      |     1 |    52 |     6  (34)| 00:00:01 |  
    |*  1 |  HASH JOIN           |      |     1 |    52 |     6  (34)| 00:00:01 |  
    |   2 |   TABLE ACCESS FULL  | T1   |     1 |    26 |     2   (0)| 00:00:01 |  
    |   3 |   VIEW               |      |     1 |    26 |     3  (34)| 00:00:01 |  
    |   4 |    HASH GROUP BY     |      |     1 |    13 |     3  (34)| 00:00:01 |  
    |   5 |     TABLE ACCESS FULL| T1   |     1 |    13 |     2   (0)| 00:00:01 |  
    Query Block Name / Object Alias (identified by operation id):                  
       1 - SEL$1                                                                   
       2 - SEL$1 / T1@SEL$1                                                        
       3 - SEL$2 / V@SEL$1                                                         
       4 - SEL$2                                                                   
       5 - SEL$2 / T1@SEL$2                                                        
    Predicate Information (identified by operation id):                            
       1 - access("T1"."C1"="V"."C1")                                              
    Column Projection Information (identified by operation id):                    
       1 - (#keys=1) "T1"."C1"[NUMBER,22], "T1"."C2"[NUMBER,22],                   
           "V"."CNT"[NUMBER,22]                                                    
       2 - "T1"."C1"[NUMBER,22], "T1"."C2"[NUMBER,22]                              
       3 - "V"."C1"[NUMBER,22], "V"."CNT"[NUMBER,22]                               
       4 - (#keys=1) "C1"[NUMBER,22], COUNT(*)[22]                                 
       5 - "C1"[NUMBER,22]                                                         
    Note                                                                           
       - dynamic sampling used for this statement                                  
    40 rows selected.
    Elapsed: 00:00:00.01
    UKJA@ukja102>
    UKJA@ukja102>
    UKJA@ukja102> @end
    UKJA@ukja102> set echo offDion Cho

Maybe you are looking for