?
Solved

sql command to rename a field once query results are displayed

Posted on 2008-10-21
2
Medium Priority
?
1,152 Views
Last Modified: 2012-08-14
i have been able to rely on ms access for years, but job duties are getting a bit more cumbersome and trying to delve into the sql world.  in access all you have to do to rename a field name in the query setup is "new field name":"current field name" - basically monkey work.  how is it done in an sql statment?  for instance if the field in quest is "run_yr_mo" and is sourced from a table call "mtgmgr.acct.mstr" and i want the field name to display as "DATE" when the query results are returned, what is the command sequence?  help features seem to indicate the following:
SELECT MTGMGR.ACCT_ACCTMSTR.RUN_YR_MO as [DATE] . . .
0
Comment
Question by:mbilicic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 100 total points
ID: 22767504
The sample above is how it's done: if you want to override the original column name, just follow it in the
select clause with AS TheNameYouWant.  Access does the same thing, except that the nice friendly
GUI hides the SQL being generated behind the scenes...
0
 
LVL 1

Assisted Solution

by:GeniusSteals
GeniusSteals earned 100 total points
ID: 22767559
You can use AS to alias all sorts of objects which will make them easier to reference, and your code easier to read.

Therefore you could have

SELECT mainTable.run_yr_mo AS Date
FROM mtgmgr.acct.mstr AS mainTable
ORDER BY Date

Notice that once a field is aliased you can then ORDER the results by the alias
0

Featured Post

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question