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 |
|
mapidea
Posting Yak Master
124 Posts |
Posted - 2009-01-31 : 23:51:29
|
| What does the following query returnsSelect * from Products p1Where 3 = ( Select Count(*) from Products p2 where p1.Price > p2.price)Thanks |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-01 : 00:21:23
|
| It should give everything including your 4th Highest price in Product table. |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-01 : 00:31:35
|
In SQL 2005 It will be:Select * from(Select Dense_Rank() over( order by Price desc) as ID,* from dbo.Products)ZWhere Z.ID =4 |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-01 : 01:01:15
|
| [code]Select Columns from(Select Columns,Price,(Select Count(distinct price) from Products Where Price >= t.Price)as ROW_IDfrom Products t)ZWhere Z.ROW_ID= 4[/code] |
 |
|
|
mapidea
Posting Yak Master
124 Posts |
Posted - 2009-02-02 : 10:29:35
|
| Thanks |
 |
|
|
|
|
|