Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With SQL QUERY

Status
Not open for further replies.

logic4fun

Programmer
Apr 24, 2003
85
US
Hi all,
I am new to this world of SQL fun and am trying to optimize my things..i have the following table :

Ctype calltime holdtime
0 256 120
1 123 234
0 88 121
0 56 10
1 121 68

from the above table i want to derive the following

TOTAL_CALL_ANSWERED (this is when the Ctype is 0 i.e. count of 0 's in Ctype column)
TOTAL_CALL_CANCELLED (this is when the Ctype is 1)
TOTAL_CALLTIME
TOTAL_HOLDTIME
AVG_CALLTIME( total_calltime/total_call_answered)
AVG_HOLDTIME( total_holdtime/total_call_answered)


For the above what i did is i wrote a Embedded sql program in C where i get individual values Using query

select calltime,holdtime,CASE when Ctype = 0 then 'A'
when Ctype = 1 then 'C' END
from <table Name>;

and then i am taking the above stuff into variables and playing with them..BUT I WANTED TO DO IN SINGLE QUERY ...Is that POSSIBLE..

thanks in advance..
Logic4fun
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top