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.
| Author |
Topic |
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-06-26 : 02:46:44
|
| Dear All,I Got Slightly Cofused The Following two Queries. Previously I used the 1st Query to find biggst Number But My friend said me Don't pass the values to from Caluse, try to pass The Values in Where Clause.So Finaly I write the 2 Query. But Performace Wise The second Query is Bad.Please suggest Me Query 1)Select Min(ColFind) From (Select top 1 ColFind from FindBig Group By ColFind order by ColFind Desc)as aQuery 2)Select Colfind from ( Select colfind from Findbig group by Colfind ) a Where 1 = ( Select Count(*)+1 from ( Select colfind from Findbig group by Colfind ) b where a.colfind <b.colfind )Thanks-- KK |
|
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-06-26 : 02:47:53
|
| Create Table FindBig (ColFind Numeric(8))Declare @numCnt Numeric(8)Select @numCnt = 1While @numCnt< 10 Begin Insert FindBig Select @numCnt Select @numCnt = @numCnt+1 End-- KK |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-26 : 02:55:46
|
Why can't you use this ?select max(ColFind) from FindBig KH |
 |
|
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-06-26 : 03:01:25
|
quote: Originally posted by khtan Why can't you use this ?select max(ColFind) from FindBig KH
If It's like fifth max means..?I just put 1 sa example. Exactly i need 30 th maximum -- kk |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-06-26 : 03:12:20
|
| That's fineThanks-- KK |
 |
|
|
|
|
|