#!bin/bash#作者:liusingbon#功能:统计 Linux 进程相关数量信息,running(运行的进程),sleeping(睡眠中的进程),stoped(停止的进程),zombie(僵尸进程)running=0sleeping=0stoped=0zombie=0#在 proc 目录下所有以数字开始的都是当前计算机正在运行的进程的进程 PID#每个PID编号的目录下记录有该进程相关的信息for pid in /proc/[1-9]*doprocs=$[procs+1]stat=$(…
1.统计每分钟内 url 的访问数量 SELECT SUBSTRING(CONVERT(varchar(100), date, 20), 0,17) as dateTime,COUNT(url) as count,url,referer FROM demo GROUP BY url,(SUBSTRING(CONVERT(varchar(100), date, 20), 0,17) ),referer;…
1.使用 DATENAME() 函数 SELECT DATENAME(yyyy, [columnName]) + '/' + DATENAME(mm, [columnName]) AS monthDate,COUNT(*) AS number FROM [tableName]GROUP BY DATENAME(yyyy, [columnName]) ,DATENAME(mm, [columnName])ORDER BY monthDate DESC 结果如下: DATENAME ( datepa…
1.可以使用count SELECT count(name='A' OR NULL) FROM table 2.用sum SELECT sum(if( = 'A', 1, 0)) FROM table 以上只是简单的方式,如遇到复杂的多表查询,可以结合GROUP BY,count() or sum()函数得出对应数据…
Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the subsequence ai, ai+1, ..., aj. Input Line 1: n (1…
#!/usr/bin/python #-*- coding: utf- -*- import os import re rawfile = '/var/log/auth.log' def rawparse(rawfile): ipdict = {} fhandle = open(rawfile,'r') regexp = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') for line in fhandle: result = regexp.fi…
A - D-query Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the subsequence ai, ai+1, ..., aj. Input L…
<script type="text/javascript"> var tags = document.getElementsByTagName('*'); var tagsArr = []; function countTag(){ for (var i = 0; i < tags.length; i++) { tagsArr.push((tags[i].tagName).toLowerCase()); } var temp = []; //该数组用于存放相同的元素…
在使用group by进行查询结果分组的时候,报错: 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'goodsinfo.item.amount' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=o…
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script type="text/javascript"> var num1 = 1; var num2 = 0; var sum = 0; var mon = prompt("请输入你所…
1.简单的,按月统计数量 SELECT CREATE_DATE, DATE_FORMAT(CREATE_DATE, '%Y-%m') AS month , COUNT(*) AS sum FROM pt_user GROUP BY month; 2.按月累加统计数据 SELECT a.month, SUM(b.total) AS total FROM ( SELECT DATE_FORMAT(CREATE_DATE, '%Y-%m') AS month, SUM(sum) AS total FR…