In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to achieve mysql every N lines to generate a summary line, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
There are three ways to deal with the need to generate a summary line every N lines
Select when c is null then 'summarize' else 'end spark ifnull (cMagneSumc) c from (
Select ceil (id/3) lg.cPol null sumc
From
(
Select @ id:=@id+1 id, t 1.* from t T1, (select @ id:=0) vars
) T2
Union all
Select ceil (id/3) lrecast nullpeng from
(
Select @ id1:=@id1+1 id, t 1.* from t T1, (select @ id1:=0) vars
) T3
Group by l
) t order by lpentry if null (cpendium 9999')
Results:
The second move is to complete the digital auxiliary watch. The performance is good. Calculating summary lines is a little more complicated to understand.
First add a digital auxiliary table nums
Table (int null) delimiter $$
Procedure pCreateNumscnt)
Declare s default
Truncate nums while s = intoselect
Set=+
End
$
Create (intbegin
Int 1 table
Insert nums s while S2 = intoselect+from
Set=*
End
$
Initialize the digital auxiliary table
Select if null (cmencc) c
From (
Select
When rn is null then 'summary' else''end s
T4.c
If (mod (t3.idjol 4)! = 0, when @ total=-1 then @ total:=t4.c else @ total:=@total+t4.c end,@total) cc
When mod (t3.idPol 4) = 0 then @ total:=-1 else null end
From (
Select * from nums where id
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.