Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
louiedogg418
Starting Member
28 Posts |
Posted - 2011-04-22 : 12:23:58
|
| What is the statement that changes the name of a column jsut for reporting but does not change the column name for good? I.e. 'Emp_sal' to 'Salary'? is it an AS statemnt? and how is this used?Thank you! |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-04-22 : 12:27:16
|
| SELECT Emp_Sal as 'Salary'FROM yourTable. It doesn't change anything in the table, just the display name in the result set.JimEveryday I learn something that somebody else already knew |
 |
|
|
louiedogg418
Starting Member
28 Posts |
Posted - 2011-04-23 : 11:42:33
|
| select avg(sal) from employee as Averagequery works but still isnt changing the name.... if i put single quotes around average i get error 102 |
 |
|
|
jeffw8713
Aged Yak Warrior
819 Posts |
Posted - 2011-04-23 : 12:55:06
|
| In your query, you aliased the table - not the column. Your query should be:SELECT avg(t.sal) AS Salary FROM dbo.Employee AS tIn this query, I have aliased the table as 't' and aliased the column as Salary.Jeff |
 |
|
|
|
|
|