MS SQL Server Concepts and Programming Question:
Download Questions PDF

How To Name Query Output Columns in MS SQL Server?

Answer:

Each column in the query output has a default name. If you don't like the default name, you can specify a new name for any column in the query output by using the AS clause. The following statement shows you a good example:

SELECT tag AS Category, YEAR(created) AS Year,
COUNT(*) AS Counts FROM ggl_links
GROUP BY tag, YEAR(created) ORDER BY COUNT(*) DESC
GO
<pre>
Category Year Counts
HTML 2003 1
SQL 2004 1
SEO 2005 1
Jobs 2006 1
XML 2006 1
XSL 2007 1
JavaScript 2007 1
</pre>

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
How To Write an Inner Join with the WHERE Clause in MS SQL Server?What Is a Subquery in a SELECT Query Statement in MS SQL Server?