rank

How do I Handle Ties When Ranking Results in MySQL?

How does one handle ties when ranking results in a mysql query? I've simplified the table names and columns in this example, but it should illustrate my problem: SET @rank=0; SELECT student_names.students, @rank := @rank +1 AS rank, scores.grades FROM student_names LEFT JOIN scores ON student_names.stude...

A Relation based page rank algorithm for semantic web search engine

what is the work flow of page rank algorithm? ...

How do I get the position of a result in the list after an order_by?

I'm trying to find an efficient way to find the rank of an object in the database related to it's score. My naive solution looks like this: rank = 0 for q in Model.objects.all().order_by('score'): if q.name == 'searching_for_this' return rank rank += 1 It should be possible to get the database to do the filtering, using order_...

Update the rank in a MySQL Table

I have the following table structure for a table Player Table Player { Long playerID; Long points; Long rank; } Assuming that the playerID and the points have valid values, can I update the rank for all the players based on the number of points in a single query? If two people have the same number of points, they should tie...

SQL Rank query optimization

I have the following table structure for a table Player Table Player { Long playerID; Long points; Long rank; } Assuming that the playerID and the points have valid values, can I update the rank for all the players based on the number of points in a single query? If two people have the same number of points, they should tie fo...

Mysql - Rank field for a query

How can I add a field that contains a rows rank within the result set of a query? Initially I used php to rank my results as it was all on a single page. Now I have added multiple pages so now even though I am on the second page the first result on the page is still '1st'. Obviously I could multiply the page number by the number of resu...

Problem with ranking of search results in SharePoint 2007 if using the CONTAINS predicate

While writing a front-end for the SharePoint Search web service for work, I did some quick testing with the MOSS Search Tool to make sure things were working right under the hood. What I found was that queries composed only of CONTAINS predicates (FREETEXT ones were fine) would have a rank of 1000 for any results that were returned. Acc...

relation between ranks of processes after using MPI_COMM_split

I used MPI_Comm_split to split the default MPI communicator.If initially there were 10 processes in default communicator ,MPI_COMM_WORLD and ,say, their ranks were identified by id_original. The new communicator consisted of 4 processes with id_original 6,7,8,9.These processes will have ranks defined by , say , id_new in the new communi...

How to get rank based on SUM's?

I have comments table where everything is stored, and i have to SUM everything and add BEST ANSWER*10. I need rank for whole list, and how to show rank for specified user/ID. Here is the SQL: SELECT m.member_id AS member_id, (SUM(c.vote_value) + SUM(c.best)*10) AS total FROM comments c LEFT JOIN members m ON c.a...

SQL Scenario of allocating ids to user

I have an sql scenario as follows which I have been trying to improve. There is a table 'Returns' which is having ids of the returned goods against a shop for an item. Its structure is as below. Returns ------------------------- Return ID | Shop | Item ------------------------- 1 Shop1 Item1 2 Shop1 Item1 3 ...

Solr/Lucene user click based ranking

I am facing the problem of sort Lucene results based on user click log. I would like that more accessed results comes first. Does anyone knows how to configure or implement such property in Lucene or Solr? Thank you very much. ...

simple rank formula

I'm looking for a mathmatical ranking formula. Sample is 2008 2009 2010 A 5 6 4 B 6 7 5 C 7 8 2 I want to add a rank column for each period code field rank 2008 2009 2010 2008 2009 2010 B 6 7 5 2 1 1 A...

How do I find the top N batters per year?

I'm playing around with the Lahman Baseball Database in a MySQL instance. I want to find the players who topped home runs (HR) for each year. The Batting table has the following (relevant parts) of its schema: +-----------+----------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default ...

How to display a students rank out of hundred students using PHP & MySQL?

I'm trying to get the rank of a certain student out of a class of a hundred, I want to be able to display the students rank. I'm trying to get the rank of a student by grades and grade points. For example if student 1 has 2 A+ grades with a total of 10 points and student 2 has 3 B- grades with a total of 10 points student 1 will rank hi...

How to select a row for certain (or give preference in the selection) in mysql?

Need your help guys in forming a query. Example. Company - Car Rental Table - Cars ID NAME STATUS 1 Mercedes Showroom 2 Mercedes On-Road Now, how do I select only one entry from this table which satisfies the below conditions? If Mercedes is available in Showroom, then fetch only that row. (i.e. row 1 in above examp...

Evaluating ranks with crowdsourcing

I have three ordered ranks of web pages for a set of queries and would like to decide which rank performs better across all queries. Imagine that for 50 queries I have collected the top 10 results from Google, Bing and Yahoo. I would like to design a crowdsourcing experiment to decide which rank is better. Thanks in advance for any comm...

mysql: group by ID, get highest priority per each ID

I have the following mysql table called "pics", with the following fields and sample data: id vehicle_id filename priority 1 45 a.jpg 4 2 45 b.jpg 1 3 56 f.jpg 4 4 67 cc.jpg 4 5 45 kt.jpg 3 6 67 gg.jpg 1 Is it p...

Help me to make a algorithm to determine the Rank of a Matrix

I want to make a program which will determine the Rank of a given Matrix in C# Console Application. But I cannot able to make the algorithm for that. Can you please help me make that algorithm? ...

Determine position of first occurence of string in MySQL?

For a table like this: username | time --------------------------------------- animuson | 0.678 aP*animuson | 0.967 animuson | 0.567 qykumsoy | 0.876 I'm trying to find a way in MySQL to order these by times and then find the position where username occurs and username is only counted once. So, if I'm s...

MySQl : How to Exclude Row in a Ranking Sub-query

Hi, I've got a mySQL statement that selects some data and also ranks. I want to have the record for 'Bob', for example, selected but NOT included in the ranking. So, I need Bob's row returned in the main select statement, but I need Bob excluded from the sub-SELECT which handles the ranking. I needs Bob's data but, he should not be co...