July 18, 2005 at 12:28 pm
Hi
I have a table with the following design:
TableID Int
UserID Int
TimeKeep TinyInt
WorkQuality TinyInt
Attitude TinyInt
Where the user gets rated out of 10 for each of the fields (TimeKeep, WorkQuality and Attitude).
What I would like is to add up all the records for each user so that I get an overall total as follows:
User1 = Sum(TimeKeep) + Sum(WorkQuality) + Sum(Attitude) Where UserID = 1
User2 = Sum(TimeKeep) + Sum(WorkQuality) + Sum(Attitude) Where UserID = 2
User3 = Sum(TimeKeep) + Sum(WorkQuality) + Sum(Attitude) Where UserID = 3
And so on, so that I get a final total for each user.
Hope I'm clear enough and someone knows of an easy way to perform this or can point me to any relevant articles.
Thanks in advance
Brendan
July 18, 2005 at 12:36 pm
Select TableID, UserID , Sum(TimeKept + WorkQuality +Attitude) As Total
From YourTable
Group by TableID, UserID
Order by TableID, UserID
* Noel
July 18, 2005 at 12:38 pm
Brendan - it sounds like you already know what to do:
select userID, (sum(timeKept) + sum(workQuality) + sum(Attitude)) as sumTotal
group by userID
noel - is your typing speed faster than Remi's ?!
**ASCII stupid question, get a stupid ANSI !!!**
July 18, 2005 at 12:41 pm
>> noel - is your typing speed faster than Remi's ?! <<
Not really, I got lucky this time
* Noel
July 18, 2005 at 12:43 pm
All, thanks for your help. As always in this forum, the help is spot on and replies are lightning fast.
Keep up the good work.
Brendan
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply