473,382 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Sql - Rankproblem

I have made this sql that works:

SELECT h1.Dato, h1.oms, (SELECT COUNT(*)
FROM tblOms AS h2
WHERE h2.oms <= h1.oms) AS Rank
FROM tblOms AS h1
ORDER BY oms;

The problem is that the lowest value get number 1. I want the higest
value to be number 1.

Is it an easy way to solve this?

Aug 25 '06 #1
2 1037
"Helge's" <he*************@chello.nowrote in message
<11**********************@i3g2000cwc.googlegroups. com>:
I have made this sql that works:

SELECT h1.Dato, h1.oms, (SELECT COUNT(*)
FROM tblOms AS h2
WHERE h2.oms <= h1.oms) AS Rank
FROM tblOms AS h1
ORDER BY oms;

The problem is that the lowest value get number 1. I want the higest
value to be number 1.

Is it an easy way to solve this?
Hei Helge!

Did you try swapping for <?

....WHERE h2.oms >= h1.oms) AS Rank

--
Roy-Vidar
Aug 25 '06 #2
Helge's wrote:
I have made this sql that works:

SELECT h1.Dato, h1.oms, (SELECT COUNT(*)
FROM tblOms AS h2
WHERE h2.oms <= h1.oms) AS Rank
FROM tblOms AS h1
ORDER BY oms;

The problem is that the lowest value get number 1. I want the higest
value to be number 1.
ORDER BY oms DESC;

Peter

--
No mails please.
Aug 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.