How To Name Query Output Columns in MS SQL Server?

Submitted by: Administrator
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>
Submitted by: Administrator

Read Online MS SQL Server Job Interview Questions And Answers