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 2008 Forums
 Transact-SQL (2008)
 How to Use Case statement ?

Author  Topic 

vijay1234
Starting Member

48 Posts

Posted - 2014-09-11 : 03:23:59
Hi Friends,

I have a requirement to display total audio customers & video customers based on some condition from begin time.

If customer names any where comes with abc then it should display audio. If not then as video.

select count(distinct name) as [Audio participant count] from vw_xyz
where endpointname like '%abc%' --- Giving Aduio Count

select count(distinct endpointname) as [Video participant count] from vw_rmxproductionmeetings
where endpointname not like '%abc%' ---- giving Video Count


I want both these two fit in a single query basing on Case statement.

Kindly help me with that dear friends.

Regards,
Vijay

vijay1234
Starting Member

48 Posts

Posted - 2014-09-11 : 05:26:08
On top of the below.

There is a time stamp column.

I would want to create a SP for the below requirement, where datepart(mm), datepart(dd),datepart(yyyy) would be my input parameters.

So finally if i give the date,month & year as the inputs then for that particular day the count of video participants & audio participants should come.

Hope i'm clear with my requirement.
Go to Top of Page

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2014-09-11 : 07:02:57
Try something like:
SELECT SUM(CASE WHEN endpointname like '%abc%' THEN 1 ELSE 0 END) AS Audio, 
SUM(CASE WHEN endpointname like '%abc%' THEN 0 ELSE 1 END) AS Video
FROM vw_rmxproductionmeetings


djj
Go to Top of Page
   

- Advertisement -