2018年8月

首页2018年8月
16
Aug
0

上一行数据减去下一行数据

Oracle

--1.创建测试表
create table tmp as
select 1 id, 20 percent from dual union all
select 1 id, 30 percent from dual union all
select 1 id, 50 percent from dual union all
select 2 id, 20 percent from dual union all
select 2 id, 20 percent from dual union all
select 2 id, 20 percent from dual union all
select 2 id, 20 percent from dual;
--2.SQL实现
select id,100-sum(percent)over(partition by id order by rownum) percent
from tmp;

SQL SERVER

select b.相减字段-a.相减字段 from(select from (select Row_Number() over ( order by 排序字段 ) as RN , from Table Name) where rn%2=0) a
inner join
(select from (select Row_Number() over ( order by 排序字段 ) as RN , from Table Name) where rn%2<>0) b on a.rn=b.rn-1

mysql

select * from
(select (@i:=@i+1) as no,id from job_log ,(select @i:=0)t where job_id =131) as t1
left join
(select (@k:=@k+1) as no,id from job_log ,(select @k:=0)t where job_id =131) as t2
on (t1.no = t2.no-1)
order by t1.no

11
Aug
0

安装uwsgi出错

错误1:
centos 6.5
python 3.6
core/routing.o: In function `uwsgi_route_condition_regexp':

routing.c:(.text+0x365c): undefined reference to `pcre_free_study'
routing.c:(.text+0x3680): undefined reference to `pcre_free_study'
collect2: ld 返回 1
*** error linking uWSGI ***

解决方法:
需要先御载pcre-devel

yum remove pcre-devel
pip3 install uwsgi 
08
Aug
0

Let's Encrypt(https证书)

支持

python2.7
git

证书申请

#获取letsencrypt
git clone https://github.com/letsencrypt/letsencrypt
#进入letsencrypt目录
cd letsencrypt
#生成证书
./letsencrypt-auto certonly --standalone --email 123@123.com -d 123.com -d www.123.com

证书保存位置

/etc/letsencrypt/live/123.com/

文件说明

cert.pem - Apache服务器端证书
chain.pem - Apache根证书和中继证书
fullchain.pem - Nginx所需要ssl_certificate文件
privkey.pem - 安全证书KEY文件

Nginx配置

#打开linux配置文件,找到HTTPS 443端口配置的server
ssl_certificate /etc/letsencrypt/live/123.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/123.com/privkey.pem;

续证书有效期(默认只有90天)

./letsencrypt-auto certonly --renew-by-default --email 123@123.com -d 123.com -d www.123.com