-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: VinodK [TLabs, SCT]
Message 2 in Discussion

Here is a sample script with the select statement to achieve the same ...   Create 
table temp_values (id Int Identity(1,1), Name Varchar(100), Salary Int) 
Insert into temp_values values('BDotNet Member 1' , 1000)
Insert into temp_values values('BDotNet Member 2' , 6500)
Insert into temp_values values('BDotNet Member 3' , 100)
Insert into temp_values values('BDotNet Member 4' , 700)
Insert into temp_values values('BDotNet Member 5' , 3000)
Insert into temp_values values('BDotNet Member 6' , 1500) 
Select * from temp_values a
where 4 = (Select Count(id) from temp_values b
Where a.salary > b.Salary)   Logic: Its a prety simple Logic ... If you see the query 
I've underlined the 4 ... This means that I want the 5th largest ... Logic If Iam the 
5th value there are 4 values above me .. Got the crux I suppose ... This is the 
easiest way ... there are more complex ways using the Top operator .. this is the best 
around ...   Now WRT performance ... Junta a simple thumb rule is that any co-orelated 
subquery is costlier over a large table as the inner query gets executed for every row 
in the outer query ...   HTH, Vinod Kumar SCT Software Solutions

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to