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)
 DOBUT IN THE CONCEPT

Author  Topic 

Sarakumar
Posting Yak Master

108 Posts

Posted - 2006-05-14 : 23:02:22
Hai,
i have a requirment,
i have table
userid calloutno callinno usertype
1 10 10 Admin
2 10 15 user

if usertype = 'Admin' i need to findout the count callount and callin as 'TotalPhoneCalls'

output
userid TotalPhonecalls
1 20 (10+10)
2 15(only the callinno)

1.Can i do this without using the Table variable or in other words, how can i achieve this in the Simplest and easy way

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2006-05-14 : 23:12:43
select userid, case when usertype = 'Admin' then calloutno + callinno else callinno end TotalPhonecalls
from table

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

Sarakumar
Posting Yak Master

108 Posts

Posted - 2006-05-14 : 23:36:16
HAI,


quote:
Originally posted by derrickleggett

select userid, case when usertype = 'Admin' then calloutno + callinno else callinno end TotalPhonecalls
from table

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.

Go to Top of Page

Sarakumar
Posting Yak Master

108 Posts

Posted - 2006-05-14 : 23:36:44
HAI,
tHANKS,Got the idea to solve my problem.

quote:
Originally posted by derrickleggett

select userid, case when usertype = 'Admin' then calloutno + callinno else callinno end TotalPhonecalls
from table

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.

Go to Top of Page
   

- Advertisement -