业务背景 统计各机型最近7天bug数量来支撑一张图表: sql需要查询最近七天数据并按每天和机型进行分组 思路 1. 查询最近7天的数据 select * from table where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time ...
分类:
数据库 时间:
2020-06-02 10:57:49
阅读次数:
196
组合查询:并(union) 复合查询(compound query):也称并,执行多个查询(多条select 语句),并将结果作为单个结果集返回。 使用场景: 1、在单个查询中从不同的表返回类似结构的数据; 2、对单个表执行多个查询,按单个表查询返回数据 注意:任何具有多个where 子句的sele ...
分类:
数据库 时间:
2020-06-02 09:45:20
阅读次数:
82
1、给定一个int数组,编写方法以统计所有偶数的值。 有很多方法可以做到这一点,但是最直接的两种方法是: static long TotalAllEvenNumbers(int[] intArray) { return intArray.Where(i => i % 2 == 0).Sum(i => ...
分类:
其他好文 时间:
2020-06-02 09:43:15
阅读次数:
47
每日总结模糊查询likeselect * from 表名 where 字段 like ‘%w%’;%:表示任意字符;必须要写在引号里面,如果后边没有%说明w后面不会有字符。反之亦然select * from 表名 where 字段 like ‘李_’;_:表示一个字符;必须要写在引号里面,如果后边有 ...
分类:
数据库 时间:
2020-06-01 20:33:34
阅读次数:
93
原标题:一条垃圾SQL,把 64 核 CPU 快跑崩了! 最近系统出了一个严重问题,应用程序卡崩导致不可用,把 Oracle 数据库服务器 64 核 CPU 快被跑满了: 经定位,是因为一条垃圾 SQL 引起的!! 其实也就是一条很简单的 SQL: select ... from xxx where ...
分类:
数据库 时间:
2020-06-01 18:04:38
阅读次数:
171
--列转行 --示例1select * from (select o.sname, count(1) dataNum from t_Olm_Onlinemondata d join t_Aaa_ou o on o.ou_id = d.company_id where d.mon_time > to_ ...
分类:
数据库 时间:
2020-06-01 15:27:12
阅读次数:
71
Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has. For each kid check if th ...
分类:
其他好文 时间:
2020-06-01 13:35:45
阅读次数:
64
最近测试过程中碰到一个诡异的问题:增加相同的索引,执行相同的查询语句,在A数据库查询耗时缩短,可在B数据库查询耗时几乎不变。这让我一度怀疑B数据库有毒,然而重启大法也没能解决。最后确认问题是由于oracle优化器模式不同,导致不规范索引造成的索引失效。 下面详细看看这个例子。 增加索引语句如下: C ...
分类:
数据库 时间:
2020-06-01 13:30:46
阅读次数:
87
-- 笨重方法 delete from tb_person WHERE id NOT IN ( select id from (SELECT min(id) id FROM tb_person GROUP BY email having count(1) > 1) tm) and email in ...
分类:
数据库 时间:
2020-06-01 12:13:31
阅读次数:
126
select sum(tsage), 性别=tsgender, 人数=count(*) from tbstudent group by tsgender --当使用了分组语句 group by 或者是聚合函数的时候,在select查询列表中不能再包含其它的列名(group by 分组后的数据只有一列 ...
分类:
其他好文 时间:
2020-05-31 19:59:11
阅读次数:
90