Using column alias with CASE

It is possible to use a column alias with a CASE in a SELECT? e.g. I have this code
SELECT
CASE WHEN categ_1 = 'BASIC' THEN total_1 WHEN categ_2 = 'BASIC' THEN total_2 END
FROM totalsBut the results column name comes out as CASEWHENCATEG_1='BASIC'THENTOTAL_1WHENCATEG_2='BASIC'THENTOTAL_2END
I want to use an alias but can't get it to work with the CASE. I guessed at
SELECT
CASE WHEN categ_1 = 'BASIC' THEN total_1 WHEN categ_2 = 'BASIC' THEN total_2 END 'alias'
FROM totalswhich doesn't work.

Try without the single quotes after END
Christopher Soza
Oracle BI DBA
Orix Consultancy Services Ltd
b: http://sozaman.blogspot.com

Similar Messages

  • Using column alias for calculations in same select list

    Hi All,
    I want to use a calculated column of query to create further calculated columns in same query using column alias. I have to do so because the calculation is too big to write it everytime.
    e.g.
    Select decode(Month, 1, Tran_January, 2, Tran_February, ....) as MonthTran,
    Month, Year,
    round(MonthTran/Intrest_rate, 2) as Amount <---(using previous alias)
    from ledger;
    Thanks in advance,
    Mona

    Probably the easiest way of doing this is to write an inline view, viz
    SELECT l.Month
           , l.Year
           , round(mt.MonthTran/l.Intrest_rate, 2) AS Amount
    FROM   ledger l
           , (SELECT x.pk_col, decode(Month, 1, Tran_January, 2, Tran_February, ....) AS MonthTran
              FROM ledger x) mt
    WHERE  l.pk_colunm = mt.pk_colunm
    ; If you have any criteria in a WHERE clause on ledger you shouldn't need to repeat them providing LEDGER does have a primary key column. You may need to tweak it a bit for performance, if LEDGER is a big table.
    Cheers, APC
    Cheers, APC

  • Use column alias in another calculation

    Database:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
    Is there a way to use a column alias in an another calculation within the
    same query? Since I am using some long and complex logic to compute total1
    and total2, I don't want to repeat the same logic to compute the ratio of
    those two columns. do you have any suggestion other than nested sub-query or view?
    select
    total1 = sum(case(long complex logic)),
    total2 = sum(case(another long complex logic)),
    ratio = total1/total2
    thanks in advance

    Jimmie_M wrote:
    Database:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
    Is there a way to use a column alias in an another calculation within the
    same query? Since I am using some long and complex logic to compute total1
    and total2, I don't want to repeat the same logic to compute the ratio of
    those two columns. do you have any suggestion other than nested sub-query or view?
    select
    total1 = sum(case(long complex logic)),
    total2 = sum(case(another long complex logic)),
    ratio = total1/total2
    thanks in advanceHi,
    Use oracle's with clause
    WITH test_data
    AS
    SELECT sum(case(long complex logic)) total1,
    sum(case(another long complex logic)) total2
    from your_table_name
    SELECT total1/total2
    from test_data
    WHERE....Regards,
    Achyut Kotekal

  • ORA-00904 when use column alias in Record Group Query

    Is it possible to use column aliases in Record Group Queries?
    I have a query that runs fine in SQL*Developer, but gives me runtime errors when I use it as a Record Group Query.
    When I use it as a Record Group Query, the Form compiles, but at runtime I receive the following errors:
    FRM-40502: ORACLE error: unable to read list of values
    when I use Help - Display Error, I see:
    ORA-00904:"CHILDNAME":invalid identifier
    The query is something like this
    select decode(complex stuff here) as "childname" ....
    I've tried it with and without the double quotes surrounding the alias name, and have also tried it without using the "as" keyword.
    I would appreciate any suggestions or insights. I'm using Forms 9.0.4.
    Thanks.

    It looks like this is caused by bug 725059:
    "FILTER BEFORE DISPLAY" DOESN'T WORK IF LOV HAS COLUMN ALIASES (TRIAGE1098)
    My LOV does have the Filter Before Display turned on. Here's the text of the bug:
    IF an LOV is created with column aliases in the select statement, (eg: select ename emp_name from emp) and the LOV property "Filter Before Display" is "Yes", THEN when you attempt to filter the LOV at runtime, (eg: type '%' then press the 'Find' button) the internal WHERE clause that forms sends to the database is: WHERE column_alias LIKE '%%' This is incorrect syntax. A client-side sqlnet trace shows this. The correct syntax should be: WHERE column LIKE '%%' . The incorrect syntax results in no rows returned. However no error is displayed by forms to the user.

  • I use a yahoo email as my Apple ID. How can I use an alias with no one knowing

    How do I know if my daughter is using an alias for her iCloud/Apple id.

    Any apple id has ability to create up to three aliases that nobody would know. Purpose of creating more then one alias is to give people different email addresses. Example would be if I had automotive business and computer business, so emails addressed to [email protected] and [email protected] would go to my mail box.
    Downside - they all go to the same mail account - which is your first account alias. So if you were to go to icloud.com website and sign in with your [email protected] or [email protected] - you will still see all of those icloud.com emails (not the yahoo ones).
    Close enough?

  • Using directory alias with a wanboot installation

    I have setup a Jumpstart server and have been using it for a while without issues. Now I want to incorporate wanboot into the process so that I do not need boot servers in each of our subnets. Since the jumpstart directory structure is already in place and I have apache running on the same server, I did not want to have to recreate the whole jumpstart directory structure. So I decided to create an alias in the apache configuration for the jumpstart directory:
    root@swamphenxb:/usr/local/apache2/conf> cat httpd.conf
    <snip>
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client. The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    Alias /jumpstart /export/jumpstart
    ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
    </IfModule>
    <IfModule cgid_module>
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #Scriptsock logs/cgisock
    </IfModule>
    # "/usr/local/apache2/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    <Directory "/usr/local/apache2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
    </Directory>
    *<Directory /export/jumpstart>*
    AllowOverride None
    Options All
    Order allow,deny
    Allow from all
    *</Directory>*
    The wanboot.conf file is located in /etc/netboot and looks with the following information:
    root@swamphenxb:/usr/local/apache2/conf> cat /etc/netboot/wanboot.conf
    # Copyright 2004 Sun Microsystems, Inc. All rights reserved.
    # Use is subject to license terms.
    # ident "@(#)wanboot.conf.sample 1.2 04/01/30 SMI"
    # wanboot.conf(4): boot configuration file.
    # Please consult wanboot.conf(4) for further information. Note that
    # this interface is "Evolving" as defined by attributes(5).
    # Anything after a '#' is comment. Values may be quoted (e.g. "val").
    # <empty> means there is no value, i.e. null. The absence of any
    # parameter implies that it takes a default value (<empty> unless
    # otherwise specified).
    # <url> is of the form http://... or https://...
    # The path of the bootstrap file (within htdocs) which is served up
    # by wanboot-cgi(bootfile).
    boot_file=/jumpstart/wanboot/wanboot.s10_sparc # <absolute pathname>
    # These are used by wanboot-cgi(bootfile|bootfs|rootfs) to determine
    # whether boot_file or the bootfs is to be sent encrypted/signed, or
    # root_file is to be sent signed; the client must be setup with the
    # corresponding encryption/signature key(s) (which cannot be auto-
    # matically verified).
    # If an encryption_type is specified then a signature_type must also
    # be specified.
    encryption_type= # 3des | aes | <empty>
    signature_type= # sha1 | <empty>
    # This is used by wanboot-cgi(bootfs) and wanboot to determine whether
    # server authentication should be requested during SSL connection
    # setup.
    server_authentication=no # yes | no
    # This is used by wanboot-cgi(bootfs) and wanboot to determine whether
    # client authentication should be requested during SSL connection
    # setup. If client_authentication is "yes", then server_authentication
    # must also be "yes".
    client_authentication=no # yes | no
    # wanboot-cgi(bootfs) will construct a hosts file which resolves any
    # hostnames specified in any of the URLs in the wanboot.conf file,
    # plus those found in certificates, etc. The following parameter
    # may be used to add additional mappings to the hosts file.
    resolve_hosts= # <hostname>[,<hostname>*] | <empty>
    # This is used to specify the URL of wanboot-cgi on the server on which
    # the root_file exists, and used by wanboot to obtain the root server's
    # URL; wanboot substitutes root_file for the pathname part of the URL.
    # If the schema is http://... then the root_file will be signed if there
    # is a non-empty signature_type. If server_authentication is "yes", the
    # schema must be https://...; otherwise it must be http://...
    root_server=http://170.12.14.240/cgi-bin/wanboot-cgi # <url> | <empty>
    # This is used by wanboot-cgi(rootfs) to locate the path of the
    # rootfs image (within htdocs) on the root_server.
    root_file=/jumpstart/miniroot/miniroot # <absolute pathname> | <empty>
    # This is used by wanboot to determine the URL of the bootserver
    # (and whether bootlog traffic should be sent using http or https),
    # or whether it should simply be sent to the console.
    boot_logger= # <url> | <empty>
    # This is used by the system startup scripts. If set, it should
    # point to a file that contains name value pairs to be used at
    # start up time. For example, this file may be used to provide
    # install the values for sysidcfg and jumpscfg.
    system_conf=system.conf
    I have the client configured to boot from the web server and when I attempt to boot, I get the following message:
    {2} ok boot net - install
    Boot device: /pci@9,700000/pci@2/network@0 File and args: - install
    /pci@9,700000/pci@2/network@0: 1000 Mbps full duplex link up
    HTTP: Bad Response: 500 Internal Server Error (boot_file missing)
    Boot load failed
    I am able to see a listing of all the directories and files including the boot_file in my browser. The permissions for the /etc/netboot directory is:
    root@swamphenxb:/etc/netboot> ls -al
    total 26
    drwx------ 3 daemon other 512 Nov 20 13:09 .
    drwxr-xr-x 63 root sys 6144 Nov 2 11:43 ..
    drwx------ 3 daemon other 512 Nov 20 13:10 170.12.144.0
    -rw------- 1 daemon other 80 Nov 5 17:02 system.conf
    -rw------- 1 daemon other 3331 Nov 2 14:07 wanboot.conf
    It looks like maybe wanboot does not like the alias I am using, but I want to verify that before I move on to plan B. Thanks.
    Chuck Briggs

    Long but this is a copy of my lab configuration files for WAN boot
    */etc/ethers*
    0:3:ba:16:99:f5 wgls01
    0:3:ba:14:b9:71 wgls02
    0:3:ba:16:a5:bf wgls03
    0:3:ba:5b:c7:5b wgls04
    0:3:ba:16:9d:31 wgls05
    0:3:ba:e8:65:9 wgls07
    0:3:ba:e8:92:a9 wgls08
    0:3:ba:16:6b:27 wgls09
    0:3:ba:2b:35:c2 wgls10
    0:3:ba:5c:b0:5 wgls11*/etc/bootparams*
    wgls01 root=wgls06:/js/sparc/Solaris_10_2009-10/Solaris_10/Tools/Boot install=wgtsinf01:/js/sparc/Solaris_10_2009-10 boottype=:in   rootopts=:rsize=8192
    wgls02 root=wgls06:/js/sparc/Solaris_9_2005-09/Solaris_9/Tools/Boot   install=wgtsinf01:/js/sparc/Solaris_9_2005-09  boottype=:in   rootopts=:rsize=8192
    wgls03 root=wgls06:/js/sparc/Solaris_10_2009-10/Solaris_10/Tools/Boot install=wgtsinf01:/js/sparc/Solaris_10_2009-10 boottype=:in   rootopts=:rsize=8192
    wgls04 root=wgls06:/js/sparc/Solaris_10_2009-10/Solaris_10/Tools/Boot install=wgtsinf01:/js/sparc/Solaris_10_2009-10 boottype=:in   rootopts=:rsize=8192
    wgls05 root=wgls06:/js/sparc/Solaris_9_2005-09/Solaris_9/Tools/Boot   install=wgtsinf01:/js/sparc/Solaris_9_2005-09  boottype=:in   rootopts=:rsize=8192
    wgls06 root=wgls06:/js/sparc/Solaris_10_2009-10/Solaris_10/Tools/Boot install=wgtsinf01:/js/sparc/Solaris_10_2009-10 boottype=:in   rootopts=:rsize=8192
    wgls07 root=wgls06:/js/sparc/Solaris_10_2009-10/Solaris_10/Tools/Boot install=wgtsinf01:/js/sparc/Solaris_10_2009-10 boottype=:in   rootopts=:rsize=8192
    wgls08 root=wgls06:/js/sparc/Solaris_10_2009-10/Solaris_10/Tools/Boot install=wgtsinf01:/js/sparc/Solaris_10_2009-10 boottype=:in   rootopts=:rsize=8192
    wgls09 root=wgls06:/js/sparc/Solaris_8_2004-02/Solaris_8/Tools/Boot   install=wgtsinf01:/js/sparc/Solaris_8_2004-02  boottype=:in   rootopts=:rsize=8192
    wgls10 root=wgls06:/js/sparc/Solaris_10_2009-10/Solaris_10/Tools/Boot install=wgtsinf01:/js/sparc/Solaris_10_2009-10 boottype=:in   rootopts=:rsize=8192*/etc/hosts*
    # Fake prod subnet
    #10.64.86.30     wgls01.nz.thenational.com wgls01
    #10.64.86.31     wgls02.nz.thenational.com wgls02
    10.64.86.32     wgls03.nz.thenational.com wgls03
    10.64.86.33     wgls04.nz.thenational.com wgls04
    10.64.86.34     wgls05.nz.thenational.com wgls05
    10.64.86.35     wgls06.nz.thenational.com wgls06
    10.64.86.36     wgls07.nz.thenational.com wgls07
    #10.64.86.37     wgls08.nz.thenational.com wgls08
    #10.64.86.42     wgls09.nz.thenational.com wgls09
    10.64.86.43     wgls10.nz.thenational.com wgls10Under wgls06:/js/sparc I have many small (~85MB) directories just to load the boot code
    # find /js/sparc/Solaris_10_2008-10
    /js/sparc/Solaris_10_2008-10
    /js/sparc/Solaris_10_2008-10/Solaris_10
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/solarisn
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/liveupgrade20
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install/solarisn.class
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install/JRE
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install/liveupgrade20.class
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install/com
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install/com/sun
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install/com/sun/launcher
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install/com/sun/liveupgrade
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Installers/.install/install_common
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/rm_install_client
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/add_install_client
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/pkg_db.cpio.bz2
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/X_small.cpio.bz2
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4us
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4us/inetboot
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4us/wanboot
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4us/boot_archive
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4u
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4u/boot_archive
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4u/inetboot
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4u/wanboot
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4v
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4v/wanboot
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4v/inetboot
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/platform/sun4v/boot_archive
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/netmask
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/X.cpio.bz2
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/lu.platforms
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/Boot/lu.cpio.bz2
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/.wanboot_unneeded_packages
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/setup_install_server
    /js/sparc/Solaris_10_2008-10/Solaris_10/Tools/dialAll OS files are located at wgtsinf01:/js/sparc
    Firewalls should allow the traffic (TFTP)

  • Using URL alias with Weblogic - How do you do it?

    Bear with me I have zero experience with Weblogic.
    We use Weblogic as a component of Hyperion Planning, meaning for Hyperion Planning weblogic is installed and acts as the java application AND webserver.
    Currently our Hyperion Planning URL is http://servername:port as per security audit we need to use an alias so that users do not have straight access to the direct URL link.
    Therefore we created on the DNS a URL alias BFS.companyname.com. Now I need to associate this alias with the Planning URL which is in weblogic.
    I have logged into the weblogic admin console and see 'Virtual Hosts', I enter in the host name BFS.companyname.com and select the target which is the Hyperion Planning workspace (http://servername:port) apply changes yet nothing occurs.
    If anyone has done a URL direction could you please post the instructions on how to do so...thanks
    JTS

    Just to share this will all. The URL alias redirection is done within Apache webserver and not the Weblogic program.
    Edit the httpd.conf file with this information below:
    1. Configure Apache to listen on port 80:
    a. Back up the configuration file, e:\Hyperion\common\httpServers\Apache\2.0.52\conf\ht tpd.conf
    b. Add "Listen 80" to the Listen section.
    c. In the Virtual Hosts section, (around line 955), uncomment the line, "NameVirtualHost *:19000"
    d. Add "NameVirtualHost *:80"
    e. Uncomment the "<VirtualHost *:19000>" code block, down to "</VirtualHost>"
    f. Edit and add the following block to Virtual Hosts
    <VirtualHost *:80>
    ServerName www.myserver.com
    DocumentRoot e:/Hyperion/common/httpServers/Apache/2.0.52/htdocs
    </VirtualHost>
    g. Restart Apache.
    2. Redirect Web Page
    a. Create a page in the virtual web directory, index.html that contains the following html code:
    <html><head>
    <meta http-equiv="Refresh" content="0; url=http://myserver:19000/workspace/index.jsp">
    </head><body>
    </body></html>
    b. Have someone in NSE alter or create a DNS entry that redirects "hyperion" to the appropriate IP address. The default page (index.html) on the default port (80) will execute the redirect in the html document above, launching the workspace login screen.
    JTS

  • How to use Substring function with Case statement.

    Hello Everyone,
    I have one requirement where I have to use substring function on the field for report criteria.
    E.G.
    I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
    now i want to substing it but the character length varies for each branch.
    so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.

    Try something like this:
    CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
    where n is the number of characters you want to start the break.

  • Selecting multiple rows using column header with checkbox in it.

    Dear All.,
    I am trying to select multiple rows with checkbox in column header but it doesnot works...
    Following is my codel
    <af:table value="#{bindings.xx.collectionModel}"
                          var="row"
                          rows="#{bindings.xx.rangeSize}"
                          emptyText="#{bindings.xx.viewable ? 'No data to display.' : 'Access Denied.'}"
                          fetchSize="#{bindings.xx.rangeSize}"
                          rowBandingInterval="1"
                          filterModel="#{bindings.xx.queryDescriptor}"
                          queryListener="#{bindings.xx.processQuery}"
                          varStatus="vs" partialTriggers="sbcSelectAll sbcChkFlag"
                          selectedRowKeys="#{bindings.xx.collectionModel.selectedRow}"
                          selectionListener="#{bindings.xx.collectionModel.makeCurrent}"
                          rowSelection="none" id="tCdMast" width="400"
                          columnStretching="column:c4" inlineStyle="height:200px;">
                  <af:column sortProperty="ChkFlag" filterable="true"
                             sortable="true"
                             headerText="#{bindings.xx.hints.ChkFlag.label}"
                             id="c2" width="55"
                             inlineStyle="#{row.ChkFlag ? 'background-color:#9CACC9;' : ''}">
                    <af:selectBooleanCheckbox simple="true" value="#{row.ChkFlag}"
                                              selected="#{row.ChkFlag}" id="sbcChkFlag"
                                              autoSubmit="true" immediate="true"/>
                    <f:facet name="header">
                      <af:selectBooleanCheckbox simple="true"
                                                autoSubmit="true"
                                                valueChangeListener="#{xxBean.onTableChkAllCheckChanged}"
                                                id="sbcSelectAll"/>
                    </f:facet>
                  </af:column>
    </af:table>
    Managed Bean
        public void onTableChkAllCheckChanged(ValueChangeEvent valueChangeEvent) {
            Boolean newValue =
                Boolean.valueOf(u.nvlString(valueChangeEvent.getNewValue(),
                                            "false"));
            Boolean oldValue =
                Boolean.valueOf(u.nvlString(valueChangeEvent.getOldValue(),
                                            "false"));
            if (newValue.equals(oldValue))
                return;
            int rowIndex=0;
            ViewObject vo = u.findIterator("xxIterator").getViewObject();
            vo.reset();
            while(vo.hasNext()){
              Row row;
              if(rowIndex==0)
                  row=vo.first();
              else
                  row=vo.next();
                 row.setAttribute("ChkFlag", newValue.booleanValue());
              rowIndex=1;
            u.addPartialTargets(tableDocuments);
        }Please help!!.
    Thanks & Regards,
    Santosh.
    jdeve 11.1.1.4.0

    Can you check this sample in the blog post?
    http://sameh-nassar.blogspot.com/2009/12/use-checkbox-for-selecting-multiple.html
    Thanks,
    Navaneeth

  • Report Query w. Column Alias issue?

    I have this query:
    SELECT
    TXI_IS_PROJECTS.PROJECT_NAME,
    TXI_IS_PROJECTS.PROJECT_DESC,
    TXI_IS_PROJECTS.PROJECT_SIZE,
    TXI_IS_PROJECTS.PROJECT_STATUS,
    (select NLS_INITCAP(name_f || ' ' || name_l) name from TXI_PEOPLE where userid= TXI_IS_PROJECTS.PROJECT_OWNER),
    TXI_IS_PROJECTS.SYSTEM_OWNER,
    TXI_IS_PROJECTS.CREATE_DATE,
    TXI_IS_PROJECTS.SPEC_REVIS,
    TXI_DOCUMENTS.NAME
    FROM TXI_IS_PROJECTS
    INNER JOIN TXI_DOCUMENTS ON TXI_DOCUMENTS.PROJECT_ID = TXI_IS_PROJECTS.PROJECT_ID
    INNER JOIN TXI_DOCUMENT_SIGNOFF ON TXI_DOCUMENT_SIGNOFF.DOC_ID = TXI_DOCUMENTS.ID
    WHERE TXI_DOCUMENT_SIGNOFF.SIGN_OFF_ID = :P9_SIGN_OFF_ID;
    The issue with this line:
    (select NLS_INITCAP(name_f || ' ' || name_l) name from TXI_PEOPLE where userid= TXI_IS_PROJECTS.PROJECT_OWNER),
    It's giving me this error:
    query column #5 ((SELECTNLS_INITCAP(NAME_F||''||NAME_L)NAMEFROMTXI_PEOPLEWHEREUSERID=TXI_IS_PROJECTS.PROJECT_OWNER)) is invalid, use column alias
    I've tried various ways and it's still not working.

    SELECT
      TXI_IS_PROJECTS.PROJECT_NAME,
      TXI_IS_PROJECTS.PROJECT_DESC,
      TXI_IS_PROJECTS.PROJECT_SIZE,
      TXI_IS_PROJECTS.PROJECT_STATUS,
      (select NLS_INITCAP(name_f || ' ' || name_l) name
       from TXI_PEOPLE
       where userid= TXI_IS_PROJECTS.PROJECT_OWNER) as "My Column",
      TXI_IS_PROJECTS.SYSTEM_OWNER,
      TXI_IS_PROJECTS.CREATE_DATE,
      TXI_IS_PROJECTS.SPEC_REVIS,
      TXI_DOCUMENTS.NAME
    FROM TXI_IS_PROJECTS
      INNER JOIN TXI_DOCUMENTS ON TXI_DOCUMENTS.PROJECT_ID = TXI_IS_PROJECTS.PROJECT_ID
      INNER JOIN TXI_DOCUMENT_SIGNOFF ON TXI_DOCUMENT_SIGNOFF.DOC_ID = TXI_DOCUMENTS.ID
    WHERE TXI_DOCUMENT_SIGNOFF.SIGN_OFF_ID = :P9_SIGN_OFF_ID;<br>
    as "My Column"<br><br>
    I just recreated it and that worked.<br><br>
    chet

  • T-SQL - Using Column Name in where condition without any references when having multiple tables that are engaged using multiple joins.

    Hi All,
    I am a newbie for T-Sql, I came across a SP where multiple tables are engaged using multiple joins but the where clause contain  a column field without any table reference  and assigned  for an incoming variable,like 
    where 'UserId = @UserId'
    instead -  no table reference like 'a.UserId = @Userid'   ............ Can any please do refer to me any material that clears my mind regarding such issue................... help is appreciated.
    Thank You.

    As suggested above, use table alias with columns for unique referencing and to make the code easier to read.
    BOL example for table aliasing:
    USE AdventureWorks;
    GO
    SELECT S.CustomerID, S.Name AS Store, A.City, SP.Name AS State, CR.Name
    AS CountryRegion
    FROM Sales.Store AS S
    JOIN Sales.CustomerAddress AS CA ON CA.CustomerID = S.CustomerID
    JOIN Person.Address AS A ON A.AddressID = CA.AddressID
    JOIN Person.StateProvince SP ON
    SP.StateProvinceID = A.StateProvinceID
    JOIN Person.CountryRegion CR ON
    CR.CountryRegionCode = SP.CountryRegionCode
    ORDER BY S.CustomerID ;
    GO
    GO
    LINK:
    http://technet.microsoft.com/en-us/library/ms124824(v=sql.100).aspx
    Check the use of TABLE ALIASes and COLUMN ALIASes in the following blog:
    http://www.sqlusa.com/bestpractices2005/organizationtree/
    Without the use of aliases the code would become unreadable.
    Kalman Toth Database & OLAP Architect
    Free T-SQL Scripts
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Column Chart with Multiple axes

    Hi folks
    I am using flex 2 charts for displaying data. I want to show my data using column chart with secondary axis. However columns for multiple series are coming one over another. here is the code I have attached:-
    But I want to put columns side by side. Any thoughts will be appreciated.
    Warm Regards
    Rush-me

    Any thoughts?
    Warm Regards
    Rush-me

  • Column alias

    Hi,
    in oracle express, on a report querry region I give this :
    select 'PINS - # of times an item in the library cache was executed - '||
    sum(pins),
    'RELOADS - # of library cache misses on execution steps - '||
    sum (reloads),
    'RELOADS / PINS * 100 = '||round((sum(reloads) / sum(pins) *
    100),2)||'%'
    from v$librarycache
    But I receive :
    1 error has occurred
    query column #1 ('PINS-#OFTIMESANITEMINTHELIBRARYCACHEWASEXECUTED-'||SUM(PINS)) is invalid, use column alias
    Any idea ? Any help ?
    Many thanks.

    You need to define column aliases.
    SQL> SELECT 'PINS - # of times an item in the library cache was executed - ' || SUM (pins) AS LibRatio,
      2         'RELOADS - # of library cache misses on execution steps - ' || SUM (reloads) AS MissRatio,
      3         'RELOADS / PINS * 100 = ' || ROUND ((SUM (reloads) / SUM (pins) * 100), 2) || '%' AS Ratio
      4    FROM v$librarycache
      5  ;
    LIBRATIO                                                                                               MISSRATIO
    PINS - # of times an item in the library cache was executed - 10455253                                 RELOADS - #

  • Issue with Column Alias Name in a SELECT statement

    I am trying to run sql query(IN ORACLE) to get the data from a remote database(TERADATA). The query is
    select (table1.exp_date - table1.setup_date) AS day_diff,
    CASE
    WHEN day_diff = '0'
    THEN 'YES'
    WHEN day_diff > '0'
    THEN 'NO'
    ELSE 'Unknown'
    END AS alias_type
    from table1@remote_database_name;
    The query is running fine when I run it in TERADATA environment directly without the remote database link since it is not necessary. If I run the above query in Oracle I am getting an error ORA-00904: invalid identifier.(this error is pointing to day_diff alias name)
    Can anyone help me with this?
    Thanks

    The Column alias can be used in the ORDER BY clause, but not other clauses,like WHERE clause, in the query.
    Use..
    select (table1.exp_date - table1.setup_date) AS day_diff,
    CASE
    WHEN (table1.exp_date - table1.setup_date) = '0'
    THEN 'YES'
    WHEN (table1.exp_date - table1.setup_date) > '0'
    THEN 'NO'
    ELSE 'Unknown'
    END AS alias_type                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • 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

Maybe you are looking for

  • GOS problem

    hi, i have implemented generic object services in an HR transaction. In an PAI-user exit i do the following: CASE innnn-infty.        WHEN '2001'.       gf_pakey-pernr = innnn-pernr.       gf_pakey-subty = innnn-subty.       gf_pakey-objps = innnn-ob

  • Inserting still images into video

    I have PS CS4 Extended, and I am pretty new to working with video.  I need to insert still images into several continuous frames of video after removing the frames that are there. Can anyone help point me in the right direction?

  • Trying to Import iDVD dvd Image to another Computer.

    I do not have a DVD Burner in my Computer, so I created the DVD Image hoping that I could transfer this image to my other PC which does have a DVD burner....but it is not letting me. Something about "file could not be moved because ""Videos" cannot b

  • Video Capture Challenge

    Here is my challenge: Running Power Mac G4 Tower w/ OS 10.4 I'm trying to remote operate 2 Pan/Tilt/Zoom cameras and have a second video feed come to the G4 to view the 2 camera signals and be able to cue camera B while Camera A is broadcasting. I ne

  • Best way to upload RAW photos to internet from iPad

    If I am on a trip and 64GB isnt enough storage for my RAW photos (and I am without my MacBook Pro), what is the best way to upload my pics in full RAW format to an internet location. Apps? Best site to store them on in full RAW? Thanks for the help!