Reputation: 765
I am querying a database as:
SELECT SUM(Hours)
from User
where surname = 'johnson';
Whenever I run it, as you know it will show selected Column with the name SUM(Hours).
Is there any way that I can "rename" it without altering the database table?
Upvotes: 0
Views: 94
Reputation: 1263
SELECT SUM(Hours) as hours from User where surname='johnson';
Upvotes: 1
Reputation: 5356
You have to do something like this:
SELECT SUM(Hours) AS sumHours FROM User WHERE surname='johnson';
Now your column name is sumHours
. You can name it whatever you want, but keep in mind to be descriptive.
Upvotes: 5