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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 And SQL Problem for your all-knowning consumption.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-29 : 07:20:45
Daryl writes "Through hours of TEDIOUS work, I have managed to get the following SQL statements. I need all of the information from both, and I am not sure how I can go about combine them.

If you feel you can offer me _any_ suggestions, I would be quite grateful.

One of the issues that you might care to know about, is that the database is not MS SQL Server, rather Sybase SQL Server. They are both extremely similar, so I hope that it is not that much of a problem. Here are my two SQL statements, and sample output data:

Many thanks,
Daryl Jones

[Statement #1:]
SELECT ad.agent_login, (ad.lname + ', ' + ad.fname) AS Agent_Name, sum(ihi.rec_count) AS Connects, sum(talk_duration) AS Talk_Time,
sum(wrap_duration) AS Wrap_Time, sum(avail_duration) AS Idle_Time, sum(wrap_duration) / sum(ihi.rec_count) AS Avg_Wrap
FROM d_app_define apd, d_agent_define ad, i_hist_agent_data had, i_hist_input ihi, d_ccr_define ccd
WHERE had.app_id = apd.app_id
AND ad.agent_id = had.agent_id
AND had.interval_tstamp >= 992995200
AND had.interval_tstamp <= 993081598
AND ihi.interval_tstamp = had.interval_tstamp
AND ihi.agent_id = ad.agent_id
AND ccd.ccr_id = ihi.ccr_id
AND ccd.app_id = had.app_id
AND apd.name = 'INBOUND'
GROUP BY apd.app_id, ad.agent_id
ORDER BY apd.name, ad.lname

[Sample Output #1:]

agent_login      Agent_Name                                                     Connects   Talk_Time  Wrap_Time  Idle_Time  Avg_Wrap   
---------------- -------------------------------------------------------------- ---------- ---------- ---------- ---------- ----------
ALEXAP ALEXANDER, PATRICK 8 1365 1079 180 134
ALMEIT ALMEIDA, TANYA 10 1059 648 217 64
BALTAM BALTA, MONIKA 18 3034 558 20 31
BARCAJ BARCA, JOHN 1 18 247 0 247
BROWNJ BROWN, JOAN 10 1590 2650 29 265
CIBC CIBC, CIBC 2 180 6 1 3
CRAWFY CRAWFORD, YVETTE 10 3237 1067 227 106
CIBCCATHY CRISPO, CATHY 2 808 47 0 23
CIBCVITO CURALLI, VITO 1 4 0 0 0
CUSCIA CUSCIANNA, ANDREW 55 9543 3615 13223 65
DAYB DAY, BRIAN 3 1106 1183 0 394
DELGAM DELGARNO, MURRAY 250 26242 12190 39173 48
DIASL DIAS, LOUISA 5 1391 877 0 175
FULLEF FULLERTON, FIONA 20 1940 238 1792 11
ISSAD ISSA, DIMA 17 4683 3071 199 180
KOTSON KOTSOVOLOS, NIKKI 26 3468 300 657 11
KULINK KULINA, KATHY 5 788 5
   

- Advertisement -