Column Alias question

H1. Oracle 10


The SQL below gives me the following error...

* S0022 (904) [Microsoft] [ODBC for Oracle driver] [Oracle] ORA-00904: 'APPROVED_TRANS': identifier invalid (0.06 seconds) *.

If I delete the alias from the statement of the AMOUNT and replace "Approved_Trans" by "CHG_APRV_DISPUTE_AMT" in the WHERE clause, it works...

Can someone explain what Oracle thinks that it doesn't?

Thank you


Tom





Select A.DISPUTE_ID,
D.DISPUTE_ID,
Approved,
Sum (CHG_APRV_DISPUTE_AMT) Approved_Trans
APPROVED_DISPUTE_TRANS a

Join them)
Select DISPUTE_ID,
(LBI_AR_ITD_APRV_AMT + MBI_AR_ITD_APRV_AMT +)
ABI_AR_ITD_APRV_AMT + LPD_AR_ITD_APRV_AMT + APD_AR_ITD_APRV_AMT) approved
the DISPUTE settlement
) D

On A.DISPUTE_ID = D.DISPUTE_ID

Where Approved_Trans =! Approved

A.DISPUTE_ID group,
D.DISPUTE_ID,
Approved;

Select expression list alias cannot be referenced in the WHERE clause. In addition, sum is the aggregation function and aggregation takes place AFTERWARDS where the provision is applied. You must use the HAVING clause:

select  A.DISPUTE_ID,
        D.DISPUTE_ID,
        Approved,
        sum(CHG_APRV_DISPUTE_AMT) Approved_Trans
  from  APPROVED_DISPUTE_TRANS A
       join (
             Select  DISPUTE_ID,
                     LBI_AR_ITD_APRV_AMT + MBI_AR_ITD_APRV_AMT + ABI_AR_ITD_APRV_AMT + LPD_AR_ITD_APRV_AMT + APD_AR_ITD_APRV_AMT Approved
               from  DISPUTE
            ) D
       on A.DISPUTE_ID = D.DISPUTE_ID
  group by A.DISPUTE_ID,
           D.DISPUTE_ID,
           Approved
  having sum(CHG_APRV_DISPUTE_AMT) =! Approved
/

SY.

Tags: Database

Similar Questions

  • Column alias error in one query views

    Hello
    I was trying to drive this query

    Create view dept_sal as
    Select d.department_name, sum (e.salary)
    departments d left outer join employee e
    on e.department_id = d.department_id
    D.department_name group;

    and I received this error message...


    Error in the command line: 2 column: 25
    Error report:
    SQL error: ORA-00998: must appoint this expression with a column alias
    00998 00000 - 'must appoint this expression with a column alias.
    * Cause:
    * Action:


    I tried to put an alias to the function sum (e.salary) and it worked, but I do not understand why it is necessary or is the problem somewhere else and why an alias is needed here?

    In fact the book has not specified the need for an alias to this place... .so I wanted to know why I get this error...

    create or replace view dept_sal as
    Select d.department_name, sum (e.salary) as d_sal
    departments d left outer join employee e
    on e.department_id = d.department_id
    D.department_name group;


    view DEPT_SAL created.



    I also wanted to know if I can start a thread whenever I want to have a problem or if I can add my questions to someone
    otherwise a wire...

    Thank you
    Jayshree

    Also, I wanted to know if I can start a thread everytime I want to have a problem or I can add my questions to someone in another thread...

    Best thing you can do is to start a new thread.
    This is after you have completed :
    -Documentation
    -forums
    and found nothing.
    Do not start new threads that are FAQ...

    Adding questions to existing threads is called 'diversion' a thread and is not appreciated. Especially when you're digging up old threads.

  • Quotes in a column alias

    Possible to have double-quotes in a column alias in a projection of SQL? Long story involving Apex, Anychart v5 and how Apex appoints series of data in the XML generated for several Y axis.

    This problem can be solved easily if I can add a quotation mark in a column alias. For example
    select
      some_col as "COL1"" param1=123"
    from dual
    No comment on the Apex by using column labels to generate XML tag name values... {noformat} ;-) {noformat}

    Of course, the SQL parser like quite the format above.

    Had a look at the SQL reference guide and it does not say much in this regard. It seems that there is no work around - correct?

    Had a look at the SQL reference guide and it does not say much in this regard

    Column alias is also to respect the rules of naming of object databases? :

    »
    ...
    7 nonquoted identifiers can contain only your database character set alphanumeric characters and the underscore (_), dollar sign ($) and sign pound (#). Database links can also contain periods (.) and 'at' sign (@).
    Oracle strongly advise to use $ and # in nonquoted identifiers.

    Quoted identifiers can contain any characters and punctuation marks and spaces.
    However, or quoted or nonquoted identifiers can contain double quotes or the null (\0) character.
    ...
    «

  • ORA-00998: must appoint this expression with a column alias

    Hi all

    Creates a table as below:

    create the table analytics_Sq.tmp_incalls_mar1 as
    SELECT TRUNC (transdate) AS hour, calltype c... result of the query.


    When will execute get error: ORA-00998: must appoint this expression with a column alias

    What should I do

    Hello

    AJAX name for these columns

    'PREP' ALIAS1, TRUNC (upddate) ALIAS2,SUM(CALLDURATION)   ALIAS3
    

    Kind regards
    Prazy

  • MySQL - Alias Question

    Hi Chaps,

    Have a fast for you...

    I know that in a SQL query, you can create an alias for column name, for example.

    ...tbl_jobxml.job1 as job2


    but you can create an alias for the value contained in this column, for example.

    ...tbl_jobxml.job1='y' as job2='Complete'


    Sorry if this is a stupid question, but it is better to ask than claim ignorance!

    ????

    I don't think it will work, as you say the query to find the 'y' in the field.

    If the field has contributed to 'y' as a value, it will work fine.

    But I don't think that an alias will work on value.

  • column of question: query customerID sqlplus appear twice

    I tried several ways to view a query where indicates the client who made more than 3 rentals from 01 Nov to 31 Dec. However, for some reason any the customerID column appear twice.

    * I use 3 tables to get this result:

    Select RentalAgreement.membershipcardid as "MCardID."
    Customer.CustomerID, Customer.CNAME, Customer.Address,
    membershipcard. CustomerID, Invoice.rentc, RentalAgreement.DateAndTimeOfIssue,
    Count (RentalAgreement.membershipcardid) as 'NOfRents' RentalAgreement, customer, membershipcard, Bill
    where rentalAgreement.membershipcardid = MembershipCard.membershipcardid
    and customer.customerid = membershipcard.customerid
    "and RentalAgreement.DateAndTimeOfIssue between November 1, 2012' and 31 December 2012"
    RentalAgreement.membershipcardid group, MembershipCard.
    CustomerID, Customer.CNAME, Customer.Address, Invoice.rentc, Customer.CustomerID, RentalAgreement.DateAndTimeOfIssue;


    MCardID CUSTOMERID CNAME ADDRESS CUSTOMERID RENTC DATEANDTI
    ---------- ---------- ---------- ------ ---------- ---------- ---------
    NOfRents
    ----------
    107 N151AS of EDuois 27 27 60 11 November 12
    5

    108 28 WDuois N151AS 28 60 19 November 12
    5

    101 N193AS of ALuois 22 22 60 22 November 12
    5


    MCardID CUSTOMERID CNAME ADDRESS CUSTOMERID RENTC DATEANDTI
    ---------- ---------- ---------- ------ ---------- ---------- ---------
    NOfRents
    ----------
    101 N193AS ALuois 22 22 60 21 of November 12
    5

    101 N193AS of ALuois 22 22 60 20 November 12
    5

    101 N193AS of ALuois 22 22 60 24 November 12
    5


    MCardID CUSTOMERID CNAME ADDRESS CUSTOMERID RENTC DATEANDTI
    ---------- ---------- ---------- ------ ---------- ---------- ---------
    NOfRents
    ----------
    109 N151AS of ADDuis 30 30 60 3 December 12
    5
    Thanks for your time.
    I'm not sure if this request seems to be logical, I would be grateful to any online guide to pl/sql

    Hello

    978308 wrote:
    Hi to you for your help, I have another question about pl/sql.

    When you have a new, separate question, then you should start a new and separate thread. This thread has 4 replies and is marked as 'response '. most of the people who have not participated in this thread (and in this case, it's just you and me) are not going to start watching now. You will get much better response if you start a new thread.

    I use oracle 11.2.0. I'm trying to get a report of repairs, so I put a condition if:
    3. WHERE RETURNED > 1; - then it will only show the repair costs

    I got an error after exec report_cursor

    SQL > exec report_cursor;

    ERROR on line 1:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'REPORT_CURSOR' must be declared.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    ---------PL/PSQL-----------------------------

    The line above shows what is simply boredom!
    What follows is not just the PL/SQL code. Like many scripts, it's a mixture of SQL * more and PL/SQL (and, unwittingly, pure SQL, too).
    'SET SERVEROUTPUT ON' is a SQL * Plus command. Like all SQL * most orders, be completed before the end of the line. In this case, it means "DECLARE CURSOR report_cursor IS" is taken as part of the SET command. When I run it, I get a SQL * Plus error message "SP2-0158: unknown SET"declare"option

    SQL >
    1 set serveroutput on DECLARE CURSOR report_cursor IS

    If the first line is ignored. Since you have not started a block PL/SQL, lines 2 and 3 are considered as being a pure SQL query.

    2. SELECT INVID REFERRED, INVOICEDA, REPAIRDETAIL OF THE INVOICE
    3. WHERE RETURNED > 1;
    4 I_INVID INVOICE. INVID % TYPE;
    5 I_REPAIRFEE INVOICE. SENT % TYPE;
    6 I_DATE INVOICE. TYPE % INVOICEDA;
    7 I_DETAIL INVOICE. TYPE % REPAIRDETAIL;

    I know not why the lines 4-7 do not cause any errors, because the DECLARE has been ignored.
    From line 8, the script is interpreted as PL/SQL: it looks like an anonymous block that does not have the optional DECLARE section.

    BEGIN 8
    9 DBMS_OUTPUT. Put_line ('ID, cost and Scooter fixed Details'); ...

    Please formatting your code. It will help you as well as others.

    All you have to do is to start the DECLARE statement on a charge line:

    set serveroutput on 
    
    DECLARE
        CURSOR report_cursor IS
                SELECT  INVID
            ,         REPAIRFEE
            ,        INVOICEDA
    ...
    
  • Column alias

    Hello

    I'm using Oracle Database 11 g Enterprise Edition Release 11.1.0.6.0.
    I would like to have an Alias for my columns in a query.
    The value of the main column is a date like 201204 Alias that should appear as column header during the execution of the query should be like Apr-2012


    So I want my output as

    April-12 May-12 June-12

    201204 201205 2012 - 06


    I use a query such as
    Select "2001204". " "'|| TO_CHAR (to_date('201204','yyyymm'), 'Mon-yy') | » » »
    Double;

    This does not give me the correct results. I'm doing something wrong?


    Thank you
    FM

    IQ says:
    Hello

    I'm using Oracle Database 11 g Enterprise Edition Release 11.1.0.6.0.
    I would like to have an Alias for my columns in a query.
    The value of the main column is a date like 201204 Alias that should appear as column header during the execution of the query should be like Apr-2012

    So I want my output as

    April-12 May-12 June-12

    201204 201205 2012 - 06

    I use a query such as
    Select "2001204". " "'|| TO_CHAR (to_date('201204','yyyymm'), 'Mon-yy') | » » »
    Double;

    This does not give me the correct results. I'm doing something wrong?

    Thank you
    FM

    The datatypes/names/sizes and the number of columns in a query is called the 'projection' and is determined at the time of the analysis. This is why he cannot be determined by data without using 2 passes data (to determine what should look like the projection and a dynamic to query the data again with that dynamically generated projection).

    What you're trying to do is basically abuses the SQL engine and it's really something that is the best reporting tools that data from the request and then treat for formatting the output based on the data itself.

    {: identifier of the thread = 2309172}

  • Reference another table without specifying the referenced column: syntax question

    create table test (key primary number col1_pk,)

    number col2_fk, col1, col2 number, check constraint test_ck (col1_pk > 0 and col1 > 0),

    constraint fk_constraint foreign key (col2_fk) references test);

    in this example, for bold hand why isn't there a reference included after column

    test references?

    is it because Oracle knows he must refer to the pk column?

    > what is Oracle knows he must refer to the pk column

    Yes.

  • Table invites the column space question OBIEE 11 g

    Hello

    I have a relationship with the table view and 2 columns in section guests table. When I see the dashboard report 2 invites showing by far. How can I reduce the space between the 2 column guests?

    Any help?

    Thank you

    Prasanna

    I found the solution. The law in the 2nd column of filling. It solves the problem.

  • Database column alias problem

    When you join the fields first name and last name in my initial SQL query of my IE interactive report

    INITCAP (INDSNAME) | » '|| INITCAP (INDFNAME) AS FULLNAME,

    When you click on through the Registration Details that I get the following error in the page element in the source I'm specifying FULLNAME under Source value or expression


    FULLNAME column not found in the table MYTABLENAME


    How can I get around this?

    Thank you very much

    You have me working for the kuddos

    OK, in this case fixed the objective to the shape that you did earlier.

    In the name field, create an element in the page on this page (or change the properties of the current which generates the error) and the properties of the item to:

    Source: Source Type: PL/SQL Expression

    Source: Source of value or Expression:

    : P9_INDSNAME | : P9_INDFNAME

    or an expression of function/pl-sql like this.

    Make sure that P9_INDSNAME and P9_INDFNAME exist on this form and are normal database fields (which can be hidden if you don't show them)

  • Create table column position questions?

    Hi all

    I'm just confused the saying that the positioning of column in tables is not serious for the relational database?

    Do you agree or disagree.

    For me, I do not share. Why?
    SQL>  create table a (a char(10),b number);
    
    Table created.
    
    SQL> create table b (b number, a char(10));
    
    Table created.
    
    SQL> insert into a values ('a',1);
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> insert into b select * from a;
    insert into b select * from a
                         *
    ERROR at line 1:
    ORA-01722: invalid number
    If it isn't serious.

    Thank you

    KinsaKaUy? wrote:
    OK maybe I interpreted in the wrong sense :))

    Can you help with this problem.

    I have an EMP table with more than 10,000 rows and 500 columns.

    The developer was asked to edit a column ATTRIBUTE1 of VARCHAR2 (10) number;

    It is said that the column must be empty to change the data type, so I created a backup:

    CREATE TABLE EMP_BAK AS SELECT * FROM EMP;
    TRUNCATE TABLE EMP;
    ALTER TABLE EMP MODIFY (ATTRIBUTE1 NUMBER);

    How can I insert it using the... INSERT INTO EMP SELECT * FROM EMP_BAK;

    To aggraviate the situation the designer wants to move the position of the column in the 100th place in 10th place.
    Assuming that you can't reason with out them, how to make this task easier?

    Thank you

    Rather than create a new table and your complications mentioned above, you can follow the Sub method I guess.

    ALTER TABLE DUMMY_ATTRIBUTE1 ADD EMP NUMBER;

    UPDATE EMP
    ATTRIBUTE1 SET = DUMMY_ATTRIBUTE1
    WHERE 1 = 1;

    COMMIT;

    UPDATE EMP
    ATTRIBUTE1 SET = NULL
    WHERE 1 = 1;

    COMMIT;

    ALTER TABLE EMP CHANGE ATTRIBUTE1 NUMBER;

    UPDATE EMP
    SET DUMMY_ATTRIBUTE1 = ATTRIBUTE1
    WHERE 1 = 1;

    COMMIT;

    ALTER TABLE DROP COLUMN DUMMY_ATTRIBUTE1 EMP;

  • Stacked column linking question

    APEX 4.0
    Anychart 5


    Setting SQL shaped for a stacked column or a bar chart is pretty simple.

    SELECT
    link,
    label,
    Value1,
    [value2],
    [value3,]...
    Of...


    This will allow your entire column/bar become a link.

    Is there a way to allow each value in a column/bar to post a link to another location?

    For example -.
    In view of the data set:

    Label: balls football: baseballs: Tennisballs
    East: 100:30:20
    West: 40:50:60
    North: 50:50:50

    A stacked bar will create three bars, each with three regions. If a link was specified according to the format described above, each region in the East bar link to the same place. Ditto for the bars of the West and the North. However, I have a 9 different links for this data set. Is this possible?

    Austin

    Hi Austin,.

    Yes, it is possible to define a different link to each item in your series on the chart. It goes down just in the way you write the query in the chart series. You can use a CASE statement to define a different link according to the value of the LABEL of your query, or you could make a UNION of several statements, with a different link defined in each select statement. Using your example data set, I've implemented the following example on my sample application - http://apex.oracle.com/pls/apex/f?p=36648:59 - and I have stressed the three queries used to generate the graph. The query of the 1 series uses a CASE statement, and other queries of two series are a UNION of several select statements. Is looking to achieve?

    I hope this helps.

    Kind regards
    Hilary

  • DataGrid width column resize question

    Is it possible to implement a DataGrid with absolute width columns AND columns of relative width?

    I have a datagrid that resizes with the browser window and widths of columns can be resized by the user, but the itemRenderer buttons still have to do the same width(resizable='false').

    I tried different combinations to attack this problem manually resize the columns in the resize event DataGrid, binding the function column widths, but nothing seems to work well.

    any tips/suggestions/ideas out there?

    I can post some samples of failed attempts if requested.

    OK, try this. It's 'force-TI-in-la submission' programming and isn't usually my style, but good, the other stuff apparently do not work.

    TS

  • join column Muti question

    We recently had a problem where we ran out of process on a single instance of the cluster so I will try to ask the DBA_HIST_ACTIVE_SESS_HISTORY to see which application has most of the sessions connected at the time.  After much research, I came with a view online but I can't figure out how to get the join condition to match the session ID and the session_serial # as a whole rather than individually.

    So if I run this query:

    Select distinct session_id, session_serial #.

    of DBA_HIST_ACTIVE_SESS_HISTORY

    where sample_time between to_date (28 Aug 14 12:01:00 am "," DD-MON-YY hh: mi: ss pm') and to_date (28 Aug 14 12:32:00 am ',' DD-MON-YY hh: mi: ss pm')

    and user_id! = 0

    and instance_number = 1;

    He returned 1507 lines.  That looks all right as a process parameter is set to 2000, when he made a mistake on.

    But when I try to get the number of session and group by user_id, charges are way off:

    Select e.user_id, count count (user_id)

    Join e DBA_HIST_ACTIVE_SESS_HISTORY

    (select distinct session_id, session_serial #)

    of DBA_HIST_ACTIVE_SESS_HISTORY

    where sample_time between to_date (28 Aug 14 12:01:00 am "," DD-MON-YY hh: mi: ss pm') and to_date (28 Aug 14 12:32:00 am ',' DD-MON-YY hh: mi: ss pm')

    and user_id! = 0

    and instance_number = 1) all_sess

    on e.session_id = all_sess.session_id

    and e.session_serial #= all_sess.session_serial #.

    E.user_id group;

    USER_ID COUNTY

    ---------------------- ----------------------

    30                     6

    494 16921

    479 147385

    486 779

    490                    48

    I think that if I can get the join to match somehow the session_id and session_serial # together as a pair rather than compare each session_id and session_serial # separately, it might work.  Any help would be appreciated.

    Hello

    Boneist wrote:

    I think it is because you are trying to reach the subquery for the entire table, not only the rows in the specified period.

    Anyway, your request not could not just be reduced to:

    1. Select user_id, count (user_id) cnt
    2. (select user_id, session_id, session_serial #)
    3. of dba_hist_active_sess_history
    4. where sample_time between to_date (28 Aug 14 12:01:00 am "," DD-MON-YY hh: mi: ss pm') and to_date (28 Aug 14 12:32:00 am ',' DD-MON-YY hh: mi: ss pm')
    5. and user_id! = 0
    6. and instance_number = 1)
    7. Group of user_id;

    ?

    Or maybe

    Select user_id, count (user_id) cnt

    (select DISTINCT user_id, session_id, session_serial #)

    of dba_hist_active_sess_history

    where sample_time between to_date (28 Aug 14 12:01:00 am "," DD-MON-YY hh: mi: ss pm') and to_date (28 Aug 14 12:32:00 am ',' DD-MON-YY hh: mi: ss pm')

    and user_id! = 0

    and instance_number = 1)

    Group of user_id;

  • using variable in the column alias

    Hello

    I have the following procedure to generate XML content

    declare
    out_xml XMLTYPE.
    fName varchar2 (100): = 'XXX ';
    Start
    SELECT XMLForest (annual) in the out_xml from tableA where rownum & lt; = 1 ;
    dbms_output.put_line ('XML: ' | out_xml.getClobVal ());
    end;
    /

    Output:
    & lt; Annual & gt; 130458 & lt; / Annual & gt;

    But, I'd like the output to be like below
    & lt; {color: #0000ff} XXX_ {color} annual & gt; 130458 & lt; / {color: #0000ff} XXX_ {color} annual & gt;

    I tried under SQL, but it is throwing error.
    SELECT XMLForest (annual as fName |) "_DOC_ID") in out_xml from tableA where rownum & lt; = 1 ;

    If I declare the query as string and run using the "EXECUTE IMMEDIATE", I get the desired result.
    strSQL: = ' SELECT XMLForest (annual as ' | x 1 |) ("_DOC_ID) from tableA where rownum & lt; = 1' ;
    EXECUTE IMMEDIATE strSQL in out_xml;

    But I want to keep it as a static query. pls know me if it is possible to do this output with static query.

    Thank you

    You list a version if this solution works under at least 10.2.0.3 and superior. You must use evalname(). I know it does not work sur.1 and I'm not sure what maniere.2 looks.

    declare
       out_xml XMLTYPE;
       fName varchar2(100) := 'XXX';
    begin
       SELECT XMLForest(dummy as evalname(fName || '_dummy'))
         into out_xml
         from DUAL;
       dbms_output.put_line('XML : ' || out_xml.getClobVal());
    end;
    

    Product
    XML: X

Maybe you are looking for

  • Printer is not communicating with the computer

    Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: I have problems with my Dell v305 printer I tried everything. Error message indicates that the printer is not communicating with the comp

  • When turn on goes to config. updates then stops

    When I start my Dell desktop computer, it goes to the screen saying configuration updates (3). It increased by 100%, then shuts down. He keeps repeting whenever I try, sometimes, I get a glimpse of the sign on the screen, but it goes. No way to get t

  • connect to the wifi of comments, but not host wifi

    It's a mystery. I have a Dell Inspiron 15R N5110. This laptop is one of the many devices in my house. All connected to a DLink DIR-655 router. But, this machine will ONLY connect to the wifi guest account and not the wifi of the host. Very strange. A

  • Printer drivers constantly become corrupt

    We have a great mix of Ricoh and HP printers in our environment.  They are all connected by a Server 2007 Enterprise edition Server.  Some of them use the specific print driver for HP printers, and another user a universal print driver, also a mix be

  • Smartphones blackBerry PLUG

    I had a phone in the BB world for years and ended prompting for all staff.  I have the charger mini firewire standard type plug with a charger at home, office, kitchen cars, everywhere.  Now, I get a "BOLD" and it has a different take.  What's the po