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
 Transact-SQL (2000)
 case function with row count

Author  Topic 

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2006-09-05 : 00:06:55
hi
pls give me eg for case function with row count
eg: if the row count is >1 then HIGH <1 or zero low

---these r table and column for refernce--

DECLARE
@rc tinyint ,
@var varchar(50)
set @var = (SELECT emd.tpa_id
from dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMD
where emd.tpa_id=ed.tpa_id
and
emd.empe_key=ed.division_key)


thanxs
india-bangalore

database

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-05 : 01:02:09
I think you finally will get a correct answer if you at least tell us what is wrong with the previous suggestions we have made here

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=71475
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=71485

Here is another solution
select		d.tpa_id,
case when d.it > 1 then 'High' else 'Low' end as status
from (
SELECT emd.tpa_id,
count(*) it
from dbo.EMPLOYER_DIVISION AS ED
inner join EMPLOYEE_MISC_DATA AS EMD on emd.tpa_id=ed.tpa_id and emd.empe_key=ed.division_key)
group by emd.tpa_id
) d


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-06 : 07:05:03
Well, at least you could have the decency to tell us what is wrong and even when it worked for you.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -