Joke Collection Website - Public benefit messages - Sql grouping shows the top 5
Sql grouping shows the top 5
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
- Related articles
- Happy birthday to the special leader.
- Where does Guiya Community belong?
- Before receiving the text message of 955 12, I received another call saying that it was Ping An Insurance. Please help me!
- What do you want to say to your ex most now?
- What is the roaming tariff of Gansu Mobile in Egypt?
- Xishuangbanna Tips Ten Safety Tips for Backpackers in Xishuangbanna
- China Life's renewal automatically deducted the premium, and it took three days to reply to the text message, saying that my premium could not be refunded. How can I get it back?
- Wechat sends messages in groups, why not let one of them receive them?
- How to turn off the traffic of SMS in telecom card?
- What are the birthday wishes for my daughter?