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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select distinct top 50 with 2 criteria

Author  Topic 

Sigenstroem
Starting Member

5 Posts

Posted - 2011-07-28 : 09:01:29
Hi all

I need some help with a sql statement where, I have 50 top pageranks, but it must be 50 unique urls.

I have tried this one.

SELECT distinct TOP 50 urlen, pagerank, Dato, Googleback, Googleindexed, Bingback, Bingindexed, Yahooback, Yahooindexed FROM Sider pagerank order by pagerank desc, urlen


Anyone that has an idea on how to do it.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-29 : 02:47:44
do you mean this?

SELECT pagerank, Dato, Googleback, Googleindexed, Bingback, Bingindexed, Yahooback, Yahooindexed
FROM
(
SELECT DENSE_RANK() OVER (ORDER BY pagerank desc) AS rnk,urlen, pagerank, Dato, Googleback, Googleindexed, Bingback, Bingindexed, Yahooback, Yahooindexed FROM Sider pagerank
)t
WHERE rnk<=50





------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Sigenstroem
Starting Member

5 Posts

Posted - 2011-07-29 : 11:44:11
I´m not quite sure, it fails.

'DENSE_RANK' is not a recognized function name.


But I need the 50 highest pageranks, but not the same url twice or more in the list.
I hope this helps.?

http://w3blog.dk
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-29 : 11:53:38
are you using SQL Server 2005 or above? try the below and post the result

SELECT @@VERSION

EXEC sp_dbcmptlevel 'your databasename here'

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -