Microsoft Query (Excel) not recognising Alias

  • Does anybody know why, Microsoft Query under windows XP fails to recognise the "AS" alias within the sql statement.

    Im renaming fields so that when I export the result set to excel in a pivot table, I simply drag and drop the field name, (however my coding is showing up as the field name instead)

    Microsoft Query is ignoring my AS Statement

    For example:

    select c.client_no,

      decode(c.given_names,null,c.agency_name_surname||decode(c.section,null,'',', '||c.section),ltrim(c.title||' '||c.given_names||' '||c.agency_name_surname)) as Client_Name

     from clients c

     where c.parent_client = 'CLC'

     or c.agency_name_surname like ('%COMMUNITY%')

     order by c.client_no;

     

    Therefore my field name with the pivot table is showing up as:

    decode(c.given_names,null,c.agency_name_surname||decode(c.section,null,'',', '||c.section),ltrim(c.title||' '||c.given_names||' '||c.agency_name_surname))

     

     

     

  • Have you tried encapsulating the AS in [] or '' i.e. [Client_Name] or 'Client_Name'?

     



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • select c.client_no,

    Client_Name = decode(c.given_names,null,c.agency_name_surname||decode(c.section,null,'',', '||c.section),ltrim(c.title||' '||c.given_names||' '||c.agency_name_surname))

    from clients c

    where c.parent_client = 'CLC'

    or c.agency_name_surname like ('%COMMUNITY%')

    order by c.client_no;

    The excel I last used 6 months ago did not support as alias, but did support alias =

    Tim S

  • Thanks guys for your suggestions, however it is still not working. I dont know if it is an install issue or not!

    We have recently migrated to Windows XP and were previously on Windows NT where the problem didnt exist.

    For example:

    The simple SQL statement below yields the following Error.  However if I put a ; at the end of the script, it runs and doesn't produce an error, but it drops the alias.

     

  • is DECODE an Oracle command? should you not be using CASE ? OR am I missing something obvious?

    Dave J


    http://glossopian.co.uk/
    "I don't know what I don't know."

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply