易截截图软件、单文件、免安装、纯绿色、仅160KB

sql 经典一

1.建表
create table temp(rq varchar(10),shengfu nchar(1))
2.插入数据
insert into temp values('2005-05-09','胜')
insert into temp values('2005-05-09','胜')
insert into temp values('2005-05-09','负')
insert into temp values('2005-05-09','负')
insert into temp values('2005-05-10','胜')
insert into temp values('2005-05-10','负')
insert into temp values('2005-05-10','负')
3.sql
select rq as '日期',sum(case when shengfu ='胜'  then 1 else 0 end) as '胜' ,sum(case when shengfu='负' then 1 else 0 end)  as '负' from temp group by rq
4.测试一下吧。。
     日期            胜    负
  2005-05-09   2     2
  2005-05-10   1     2


相关文档:

SQL语句PART8

PairWise subquery:
e.g.:
select * from wf_docsort where (ndocsortid,nmoduleinfoid)  in (select ndocsortid, nmoduleinfoid from wf_docsort where instr(cname,'文')>0)
the above sql is the same function as:
select * from wf_docsort where ndocsortid = (select ndocsortid from wf_docsort where ......

SQL语句PART9

Group functions
SELECT [column,] group_function(column) ... from table [WHERE condition] [GROUP BY group_by_expression] [ORDER BY column];
e.g.:
SELECT department_id, job_id, SUM(salary), COUNT(employee_id) from employees GROUP BY department_id, job_id ;
SELECT [column,] group_function(column).. ......

SQL语句PART10

oracle tips
Exist的用法:
select gw.ndocid from 
(select ndocid from wf_doc_gw_shouwen union select ndocid from wf_doc_gw_fawen) gw
where
not exists (select null from wf_doc_gw_sn sn where sn.ndocid=gw.ndocid)
2。把GW表和SN表里相同的NDOCID显示出来
select gw.ndocid from 
(se ......

Oracle、SQL Server、Access数据库高效果分页技巧

 在程序的开发过程中,处理分页是大家接触比较频繁的事件,因为现在软件基本上都是与数据库进行挂钓的。但效率又是我们所追求的,如果是像原来那样把所有满足条件的记录全部都选择出来,再去进行分页处理,那么就会多多的浪费掉许多的系统处理时间。为了能够把效率提高,所以现在我们就只选择我们需要的数据,减少数据 ......

【转】MySQL中SQL优化和架构设计的一些简单想法

普通MySQL运行,数据量和访问量不大的话,是足够快的,但是当数据量和访问量剧增的时候,那么就会明显发现MySQL很慢,甚至down掉,那么就要考虑优化我们的MySQL了。
优化无非是从三个角度入手:
第一个是从硬件,增加硬件,增加服务器
第二个就是对我们的MySQL服务器进行优化,增加缓存大小,开多端口,读写分开
第三个 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号