Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 23/11/2024 Black Friday 2024

    BIG SALE, 30% discount for all our extensions. Use BF24 coupon code. Hurry up the discount is valid till 3 December.

  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

Possible Error in Data Retreival?
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: Possible Error in Data Retreival?
#31995
Re:Possible Error in Data Retreival? 12 Years, 2 Months ago Karma: 2
I've since learned that what I need is the MySQL equivalent of Oracle's DENSE_RANK function, but with a twist: skipping number to account for ties.

I think this link will help me: www.oreillynet.com/pub/a/mysql/2007/04/12/emulating-analytic-aka-ranking-functions-with-mysql.html
The administrator has disabled public write access.
 
#32061
Re:Possible Error in Data Retreival? 12 Years, 2 Months ago Karma: 2
Got it!

Code:

SELECT
    IF(@LastScore <> Score,
        IF(@LastGame <> Games, @CurrentRank := 1, @CurrentRank := @CurrentRank + @NextRank),
        @CurrentRank) AS Rank,
    Name,
    IF(@LastScore = Score, @NextRank := @NextRank + 1, @NextRank := 1) as AddToGetNextRank,
    @LastScore := Score AS Score,
    @LastGame := Games AS Games
FROM
    (SELECT Games, Name, Score
    FROM Results
    WHERE Date='2012-09-01') x
CROSS JOIN
    (SELECT @CurrentRank := 1, @LastGame := 0, @LastScore := 0, @NextRank := 0) r
ORDER BY
    Score DESC;

The administrator has disabled public write access.
 
Go to topPage: 12