类型前的进货,退货是根据单号 'JH' 还是 'Th'来 确定。
同时要求按 jdate时间范围查找, 可以按gysb.gysbh查找。
同时要求按 jdate时间范围查找, 可以按gysb.gysbh查找。
解决方案 »
- 如何结合HOTKEY组件修改系统热键?
- 在delphi中使用RealAudio播放wmv文件格式问题
- 跪求,ado连接sql数据库时,关于adoquery的问题
- 怎样做一个没有窗体的程序
- 高手帮忙获取网易POPO的对话内容!
- 一个奇怪的问题,救命啊!
- StringGrid 编辑状态下如何垂直居中?
- 有没有在上海的Delphi爱好者
- 交换各位delphi大虾的qq了,我的为17296122
- 拨号连接到ORACLE8,在程序打开数据库后,如果掉线了,重新拨上后在程序中执行数据库操作则报错,在不重新打开程序的情况下,怎样自动重新连接数据库
- 谁手里有delphi code arrange expert 感激不尽 [email protected]
- 一个很实用的程序(建立SQL结构)和源代码送给大家,具体请进
那个不是标准的sql, 需要按的sql来做. 如PL/sql 或 ms sql会有分别.
from
(
select j.gysbh,'进货' as type,jhdh,dj,sl,dj*sl as ze,OrderType as 2
from jhmxb m,jhdb j
where m.jhdh=j.jhdh
union all
select t.gysbh,'退货' as type,thdh,dj,sl,dj*sl as ze,OrderType as 3
from thmxb m,thdb t
where m.thdh=t.thdh
union all
select a.gysbh,'小计' as type,null as thdh,null as dj,null as sl,sum(ze) as ze,OrderType as 4
from (
select j.gysbh,sum(dj*sl) as ze
from jhmxb m,jhdb j
where m.jhdh=j.jhdh
group by j.gysbh
union all
select t.gysbh,sum(dj*sl) as ze
from thmxb m,thdb t
where m.thdh=t.thdh
group by t.gysbh
) as a
union all
select gysbh,gysname as type,null as thdh,null as dj,sl,null as ze,OrderType as 1
from gysb
union all
select gysbh,null as type,null as thdh,null as dj,sl,null as ze,OrderType as 5
from gysb
) as t
orser by gysbh,OrderType
注:最好能用存储过程,要不以句sql不好理解。
select type as 类型,jhdh as 单号,dj as 单价,sl as 数量,ze as 总额
from
(
select j.gysbh,'进货' as type,j.jhdh,dj,sl,dj*sl as ze, 2 as OrderType
from jhmxb m,jhdb j
where m.jhdh=j.jhdh
union all
select t.gysbh,'退货' as type,t.thdh,dj,sl,dj*sl as ze, 3 as OrderType
from thmxb m,thdb t
where m.thdh=t.thdh
union all
select gysbh,'小计' as type,null as thdh,null as dj,null as sl,sum(ze) as ze, 4 as OrderType
from (
select j.gysbh,sum(dj*sl) as ze
from jhmxb m,jhdb j
where m.jhdh=j.jhdh
group by j.gysbh
union all
select t.gysbh,sum(dj*sl) as ze
from thmxb m,thdb t
where m.thdh=t.thdh
group by t.gysbh
) as a
group by gysbh
union all
select gysbh,gysname as type,null as thdh,null as dj,null as sl,null as ze,1 as OrderType
from gysb
union all
select gysbh,null as type,null as thdh,null as dj,null as sl,null as ze, 5 as OrderType
from gysb
) as t
order by gysbh,OrderType