MySQL some statements

Source: Internet
Author: User

<!--number of alarms ranked by creation time per month--
<select id= "Alarmdaysort" resulttype= "Alarm" >
Select Date_format (create_date, '%y-%m ') as Jltime,
COUNT (*) as Jlall
From Amp_alarm_log a group by Jltime ORDER by Jltime DESC LIMIT 12
</select>

<!--regional enterprises ranked in different regions of the number of enterprises--
<select id= "Areasort" resulttype= "Alarm" >
SELECT B. ' Name ' as AreaName,
COUNT (C.area_code) as Companysum
From Sys_area b
Left joins Amp_ent_info C on B. ' CODE ' =c.area_code
GROUP by B. ' Code ' has b. ' Code ' like ' 3307__ '
</select>

<!--alarm levels for nearly 30 days--
<select id= "Alarmlevel" resulttype= "Alarm" >
SELECT
Truncate (t2.levelhigh/t1.levelall*100,2) as Levelhighpercent,
Truncate (t3.levelmid/t1.levelall*100,2) as Levelmidpercent,
Truncate (t4.levellow/t1.levelall*100,2) as Levellowpercent
From
(SELECT count (*) as Levelall from Amp_alarm_log where Date_sub (Curdate (), INTERVAL-day) &lt;= create_date) T1,
(SELECT count (*) as Levelhigh from Amp_alarm_log a where a.level=3 and Date_sub (Curdate (), INTERVAL-day) &lt;= Crea te_date) T2,
(SELECT count (*) as Levelmid from Amp_alarm_log a where a.level=2 and Date_sub (Curdate (), INTERVAL-day) &lt;= creat e_date) T3,
(SELECT count (*) as Levellow from Amp_alarm_log a where a.level=1 and Date_sub (Curdate (), INTERVAL-day) &lt;= creat e_date) T4
</select>

MySQL some statements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.