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 |
|
TurdSpatulaWarrior
Starting Member
36 Posts |
Posted - 2005-08-26 : 15:57:42
|
| Good day all. I have arrived at somewhat of a Friday mental block and cannot seem to get the old cogs turning well enough to figure out something that sounds o simple to me in concept:Given a table containing a column of varying numeric values, how would one go about selecting the second largest number only? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-08-26 : 16:00:14
|
| SELECT MAX(Column1)FROM Table1 WHERE Column1 < (SELECT MAX(Column1) FROM Table1)Tara |
 |
|
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2005-08-26 : 16:22:43
|
quote: Originally posted by tduggan SELECT MAX(Column1)FROM Table1 WHERE Column1 < (SELECT MAX(Column1) FROM Table1)Tara
Tara, That logic is too cool----are you sure you're not a Vulcan?Semper fi, XERXES, USMC(Ret.)------------------------------------------------------The Marine Corps taught me everything but SQL! |
 |
|
|
kapilarya
Yak Posting Veteran
86 Posts |
Posted - 2005-08-28 : 04:57:43
|
| try this delcare @N int set @N = 2 Select * From Employee E1 Where (@N-1) = (Select Count(Distinct(E2.Salary)) From Employee E2 Where E2.Salary > E1.Salary) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-29 : 01:11:30
|
| Other approachselect min(col) from (select top 2 col from yourTable order by col desc) TMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|