| |

VerySource

 Forgot password?
 Register
Search
View: 739|Reply: 5

sql ranking side by side problem

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-10 23:30:01
| Show all posts |Read mode
select ROWNUM = (select sum (1) from member where member_mark> = a.member_mark),
member_id, member_mark
from member a order by ROWNUM

The correct result should be that mopaco is second.


1, Lao Li, 100
3, mopaco, 90
3, taotao3166,90
6, sports car, 70
6, ceagle, 70
6, Xiao Cui, 70
Reply

Use magic Report

0

Threads

12

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-4-5 19:45:01
| Show all posts
select
    ROWNUM = isnull ((select count (*) from member where member_mark> a.member_mark), 0) +1,
    member_id,
    member_mark
from
    member a
order by
    ROWNUM
Reply

Use magic Report

1

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-4-6 01:00:01
| Show all posts
select ROWNUM = (select sum (1) +1 from member where member_mark> = a.member_mark),
member_id, member_mark
from member a order by ROWNUM
Reply

Use magic Report

1

Threads

13

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-4-11 17:00:01
| Show all posts
Ok
There are actually other solutions
learned
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-13 01:45:01
| Show all posts
This is my own answer

select rank = (select sum (1) from member where member_mark> a.member_mark or member_id = a.member_id),
member_id, member_mark
from member a order by
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-14 10:00:01
| Show all posts
select ROWNUM = (select count (DISTINCT member_mark) from member where member_mark> = a.member_mark),
member_id, member_mark
from member a order by ROWNUM
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list