I'm looking to rank my results obtained through an inner join.
Here is my SQL query:
Code: |
SELECT t1.f1, t2.f2, t2.f3, t2.f4, t2.f5
FROM t1, t2
WHERE t1.f1=t2.f1 AND t2.f6="{date}"
ORDER BY f1, f2, f3, f4, f5;
|
The resulting row set gives me x rows.
I'd like to have a left-most column called Rank, which simply increments. If there is a tie, it'd be nice if the tied entries were all of the same rank, and then the next rank would continue as appropriate. However, I do have 5 fields in my ORDER BY portion, so I doubt that there will be any ties.
I have found this on the net, but it appears that the SQL query textbox does not like multiple statements:
Code: |
SET @rank=0;
SELECT @rank:=@rank+1 AS rank, fruit, amount
FROM sales
ORDER BY amount DESC;
|
Any thoughts?