1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

|| operator with column alias

Discussion in 'SQL PL/SQL' started by sunil_cr, Feb 11, 2015.

  1. sunil_cr

    sunil_cr Guest

    Hello,

    I have a question regarding || operator and alias columns.

    The query Give below is working successfully.

    SELECT FKI_STAFF_ID || 'T' || F_AMOUNT AS "AMOUNT" FROM TBL_ADVANCE_PAYMENT;

    But the following query do not works.

    SELECT FKI_STAFF_ID AS "SID" || 'T' || F_AMOUNT AS "AMOUNT" FROM TBL_ADVANCE_PAYMENT;

    Please can any one explain the reason for this....
     
  2. RG Hegde

    RG Hegde Forum Advisor

    Messages:
    185
    Likes Received:
    35
    Trophy Points:
    310
    Location:
    Pune
    Hello

    In the first query
    SELECT FKI_STAFF_ID || 'T' || F_AMOUNT AS "AMOUNT" FROM TBL_ADVANCE_PAYMENT;

    "AMOUNT" is the alias for column name FKI_STAFF_ID || 'T' || F_AMOUNT

    But in the second query
    SELECT FKI_STAFF_ID AS "SID" || 'T' || F_AMOUNT AS "AMOUNT" FROM TBL_ADVANCE_PAYMENT;

    You have used 2 Alias for single column "SID" & "AMOUNT" . Please check the syntax
     
    sunil_cr likes this.