| |

VerySource

 Forgot password?
 Register
Search
View: 1203|Reply: 9

The simpler the better! Simple statistics

[Copy link]

3

Threads

10

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-11-4 10:00:02
| Show all posts |Read mode
The table is as follows:
id num
11 12
12 12
13 13
14 88
15 10
.. ..

num may be repeated.

Find the number of IDs with the smallest (large) num
2/1
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Invalid IP Address

Post time: 2020-11-4 12:30:01
| Show all posts
--try
select count(*) from table a where a.num=(select min(num) from table)
group by num
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-11-4 12:45:01
| Show all posts
select count(*)'num minimum id number' from table
where id = (select min(num) from table)

Only think of the above stupid method for the time being
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-11-4 13:00:01
| Show all posts
+ AS

select count(*) AS'num minimum id number' from table
where id = (select min(num) from table)

Only think of the above stupid method for the time being
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-11-4 13:15:01
| Show all posts
select count(*) from tablename where num in (select min(num) as num from tablename)
Reply

Use magic Report

0

Threads

17

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-11-4 13:30:01
| Show all posts
select count(1) from table a where exists(select 1 from table where num>a.num) group by a.num
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-11-4 14:00:01
| Show all posts
Ha ha. . All positive solutions
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-11-4 16:30:01
| Show all posts
select top 1 from table order by num asc(/desc) -
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-11-4 16:45:01
| Show all posts
select top 1 * from table order by num asc(/desc) -
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-11-4 17:00:01
| Show all posts
select count(*) from xx where num=(select top 1 num from xx order by num desc)
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