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 |
|
jessyx
Starting Member
5 Posts |
Posted - 2008-07-24 : 12:42:28
|
| I am having some serious issues. I have a database that was designed for work reporting - and it has several different things that it tracks. One table in it (PerList) is the list of personnel employed. Another (DailyPhone) is a list of Times that each employee was in which aux code (phone state) for what duration of time.I am trying to write a query that will return to me the list of agents with each individuals times in these aux states as a sum total. What I have so far is this:SELECT PerList.LName + ', ' + PerList.FName AS FLName, PerList.ID, derivedtbl_1.Aux1, derivedtbl_1.Aux2FROM (PerList INNER JOIN PhoneDaily ON PerList.ID = PhoneDaily.ID), (SELECT SUM(Aux1) AS Aux1, SUM(Aux2) AS Aux2 FROM PhoneDaily PhoneDaily_1) derivedtbl_1WHERE (PhoneDaily.Desk = 'WY')The problem that I am having with the returned data at this point is that the Sums for Aux1 and Aux2 are coming back the same for everyone. I need to have it sum each persons indivual aux1 and aux2 in the return, not the total combined of everyones. How can I fix this? Thanks in advance! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-24 : 12:46:50
|
| [code]SELECT PerList.LName + ', ' + PerList.FName AS FLName, PerList.ID, derivedtbl_1.Aux1, derivedtbl_1.Aux2FROM PerList(SELECT ID,SUM(Aux1) AS Aux1, SUM(Aux2) AS Aux2FROM PhoneDaily PhoneDaily_1WHERE PhoneDaily_1.Desk = 'WY'GROUP BY ID) derivedtbl_1ON PerList.ID = derivedtbl_1.ID[/code] |
 |
|
|
jessyx
Starting Member
5 Posts |
Posted - 2008-07-24 : 13:13:42
|
| Thanx soooo much! Got it working :) |
 |
|
|
|
|
|
|
|