的困难主要是在编程语言上,数组,逻辑,算法,...
这些都过来了之后,困难就上升到数据库设计上了.
以及数据逻辑.
一个优秀的系统,会集成优秀的程序和优秀的数据库设计.
要做到这点得有足够的经验.
这是我写的一个结合uinon的嵌套查询.
将五个方面的报表放到一个临时表里,再从临时表里,将所要的数据查询出来.
复制代码 代码如下:
$sql="select type , sum( yjsl ) as yjsl , sum( yysl ) as yysl, sum( jyrs ) as jyrs, sum( jycs ) as jycs
from (
select c.mc as
type , count( d.lsh ) as yjsl, 0 as yysl, 0 as jyrs, 0 as jycs
from sys_dzxxb as b, sys_jcb as c, sys_dzyjb as d
where b.bm = c.lsh
and d.dzlsh = b.lsh
group by c.mc
union select c.mc as
type , 0 as yjsl, count( e.lsh ) as yysl, 0 as jyrs, 0 as jycs
from sys_dzxxb as b, sys_jcb as c, sys_dzyy as e
where b.bm = c.lsh
and e.dzlsh = b.lsh
group by c.mc
union select c.mc as
type , 0 as yjsl, 0 as yysl, count( distinct e.dzlsh ) as jyrs, 0 as jycs
from sys_dzxxb as b, sys_jcb as c, sys_ltxxb as e
where b.bm = c.lsh
and e.dzlsh = b.lsh
group by c.mc
union select c.mc as
type , 0 as yjsl, 0 as yysl, 0 as jyrs, count( distinct e.lsh ) as jycs
from sys_dzxxb as b, sys_jcb as c, sys_ltxxb as e
where b.bm = c.lsh
and e.dzlsh = b.lsh
group by c.mc
) as temptable
group by type ";
分享给大家.
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论