1.联合 union 进行多个查询语句时,要求多次查询的结果列数必须一样.此时,查询的结果以第一个sql语句的列名为准且union会自动去重复我们应该使用union all. 例...... 1.联合 union 进行多个查询语句时,要求多次查询的结果列数必须一样.此时,查询的结果以第一个sql语句的列名为准且union会自动去重复我们应该使用union all. 例如: select id,sum(num) from (select * from ta union all select * f…
SQL Server 学习系列之四(SQL 内幕) SQL Server 学习系列之一(薪酬方案+基础) SQL Server 学习系列之二(日期格式问题) SQL Server 学习系列之三(SQL 关键字) 学习<Microsoft SQL Server 2005技术内幕:存储引擎>的代码笔记备录于此: select @@VERSION select * from sys.dm_exec_requests --资源监视器 DMV select tb.status ,tb.command ,…
SQL Sever 学习系列之一 本学习系列,从实际工作需要中积累,对于一个新手而言,写出几条漂亮的查询语句,应该是可以受启发的. 一.问题的需求是:员工薪酬发放,现有资金能发放多少人,哪些人应得? /*所有的记录,从头开始累加,直到累加值大于一个给定值以后,返回之前计入累加的记录*/ 先建立相关职工薪酬表,添加测试数据: create table Table_1 ( id int identity not null primary key, name ), je ,), date d…
Sql语句学习 一. select playerId, count(playerId) as num from OperateLog_$i where playerId > 0 and rootId = 12 and typeId = 12156 and actionTime >= 1381509000000 and actionTime <= 1381511220000 group by playerId having count(*) > 2; this-- > 可以计…