SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 case function with row count
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

oracle_corrgi
Yak Posting Veteran

India
98 Posts

Posted - 09/05/2006 :  00:06:55  Show Profile  Reply with Quote
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

Edited by - oracle_corrgi on 09/05/2006 00:10:42

SwePeso
Patron Saint of Lost Yaks

Sweden
30249 Posts

Posted - 09/05/2006 :  01:02:09  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

Sweden
30249 Posts

Posted - 09/06/2006 :  07:05:03  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.44 seconds. Powered By: Snitz Forums 2000