Joke Collection Website - Public benefit messages - Sql grouping shows the top 5

Sql grouping shows the top 5

This is an oracle problem, right, sql?

Computer network server

Without the trim () function, the solution steps are as follows.

1, create a temporary table dx 1, sort by sending time, and take out rownum.

choose

Dx。 Send number, dx. Send time, dx. Development content, rownum

sx

From dx

order

pass by

transmitting time

2. For the temporary table 1 dx 1, take out the daily minimum serial number as the temporary table 2 dx2.

choose

transmitting time

Send time, minutes (sx)

sx

from

[dx 1]

group

pass by

transmitting time

3. The joint query of temporary table dx 1 and temporary table dx2 is a conditional statement.

choose

[dx 1]。 Sending number, [dx 1]. Send time, [dx 1]. The content of development.

from

[dx 1],[dx2]

where

Trunc([dx 1]。 Send time) =trunc([dx2]. Time of transmission)

and

[dx 1]。 sx & lt【dx2】。 sx+5

will

dx 1,dx2

Replace them with the original statements, and the result is as follows.

choose

Dx 1。 Sending number, dx 1. Send time, dx 1. The content of development.

from

(select

Dx。 Send number, dx. Send time, dx. Development content, rownum

sx

from

Advanced (short for deluxe)

order

pass by

Transmission time)

dx 1,

(select

transmitting time

Send time, minutes (sx)

sx

from

(select

Dx。 Send number, dx. Send time, dx. Development content, rownum

sx

from

Advanced (short for deluxe)

order

pass by

Transmission time)

group

pass by

transmission time

dx2

where

Trunc(dx 1。 Send time) =trunc(dx2. Time of transmission)

and

dx 1 . sx & lt; dx2.sx+5