Adding titles to columns in a result set

  • While executing a select query, what is the syntax to be included in the query for adding descriptive titles to each column in the result set?

    For example if I would like to query the Employee table to return information of Employee ID, First Name, Last Name, Department Name, and Salary, for all employees making more than $90,000, my basic query without column titles would read:

    SELECT employeeid, firstname, lastname, department, salary FROM Employee

    WHERE salary >= 90000.00;

  • you'll want to use the optional ALIAS for each columnname.

    descriptions with spaces require brackets or double quotes.

    based on your example, here's what it might look like:

    SELECT

    employeeid AS [Employee ID],

    firstname AS [First Name],

    lastname AS [Last Name],

    department AS [Department Name],

    salary AS [Salary]

    FROM Employee

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank you, Lowell. That's exactly what I was looking for.

Viewing 3 posts - 1 through 2 (of 2 total)

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