
sql
Datawhale
一个开源的学习组织
展开
-
数据统计脚本(一周)
1. 注册数量;提交借款申请select count(*) from agentCore.custInfo where channelid=393 and datediff(registertime,'2018-07-16')>=0 and datediff(registertime,'2018-07-22')<=0; select count(*) from agentCo...原创 2018-07-23 20:49:20 · 1111 阅读 · 0 评论 -
数据统计脚本(汇总)
1. 注册数量;提交借款申请select count(*) from agentCore.custInfo where channelid=393 and datediff(registertime,'2018-07-22')<=0; #贷款平台select count(*) from agentCore.loanCase where channelid=393 and dat...原创 2018-07-23 20:52:00 · 2336 阅读 · 0 评论 -
PostgreSQL专题
PostgreSQL中文社区PostgreSQL教程原创 2018-08-10 16:09:05 · 990 阅读 · 0 评论 -
PostgreSQL_row_number() over()
语法row_number() over( [partition by col1] order by col2[desc]) row_number() 为返回的记录定义各行编号pritition by 分组order by 排序实例实例数据来源,利用pgAdmin数据库实践建表create table student(id serial,name charac...原创 2018-08-10 16:54:05 · 2593 阅读 · 0 评论 -
PostgreSQL_row_number() over()_应用实例
任务用credit.loanborrow(用户借款表)中的数据,加工出以下字段:custidcustwholeinfoidloanborrowid (就是credit.loanborrow表的id)givemoneytime (还款时间)deductmoneytime (扣款时间)latedays (逾期天数,借款30天以上未还款就算逾期)borrowamount (借款金...原创 2018-08-10 17:42:42 · 1140 阅读 · 0 评论 -
PostgreSQL 计算逾期率
方式1selecttable1.first_0_overdue_people,table2.first_15_overdue_people,table3.second_0_overdue_people,table4.second_15_overdue_people,table5.all_people_0,table6.all_people_15,table1.first_0_ov...原创 2018-08-07 16:40:12 · 1837 阅读 · 0 评论 -
PostgreSQL_case when
描述查询6月份借款用户,在7.15的d1,d2的逾期率,分新老用户用户借款时间为6.01-6.31根据逾期天数分为d1和d2,d1表示逾期大于1天brrank确定新用户和老用户,新用户brrank=1,老用户brrank&amp;gt;1psperdno = 1 表示第一期借款-- d1 新用户(brrank=1) d2(修改latedays &amp;gt; 1)select cou...原创 2018-08-17 15:45:13 · 6735 阅读 · 0 评论 -
SQL_Case When 嵌套
select psperdno "期数",count(case when psperdno = 1 then (case when date(datadate)-psduedt > 0 then a.custid end) else (case when date(datadate)-psduedt > 15 then a.custid end) end) "总人数",count...原创 2018-08-17 18:39:10 · 1723 阅读 · 0 评论