本来的表是这样的
库存表 goods
id 货物编号,货物名称,货物库存量
出入库表 dan
货物编号,数量,日期,出入库标记
--------------------------我如果做成三个表可以吗库存表 goods
id 货物编号,货物名称,货物库存量
出货表 dan1
货物编号,数量,日期
入货表 dan2
货物编号,数量,日期
-------------------如果可以,在查询某货物在某时间段内的进出情况的语句该
怎样修改
本来的SQL语句是
query.sql.add('select * from dan where 日期>:rq1 and 日期<:rq2 and
货物编号 = 指定货物');
query.parambynaem('rq1').asdatetime:= strtodate(edit1.text)
query.parambynaem('rq2').asdatetime:= strtodate(edit2.text)
库存表 goods
id 货物编号,货物名称,货物库存量
出入库表 dan
货物编号,数量,日期,出入库标记
--------------------------我如果做成三个表可以吗库存表 goods
id 货物编号,货物名称,货物库存量
出货表 dan1
货物编号,数量,日期
入货表 dan2
货物编号,数量,日期
-------------------如果可以,在查询某货物在某时间段内的进出情况的语句该
怎样修改
本来的SQL语句是
query.sql.add('select * from dan where 日期>:rq1 and 日期<:rq2 and
货物编号 = 指定货物');
query.parambynaem('rq1').asdatetime:= strtodate(edit1.text)
query.parambynaem('rq2').asdatetime:= strtodate(edit2.text)
解决方案 »
- 请问给定一个fillname有没有直接函数可以取其盘符?好像getdrive和getdrivename是这种功能,可是它们在哪个单元呢?
- 紧急问题,摆脱高手回答,关于怎样将oracle导出为dbf格式的
- 碰到一个比较难搞的问题,高手进来看看
- 高级编程、类模板 ,函数构造TClass.Create?
- 新手的用户登录问题
- 请教:如何获取StringGrid1中某列的最大值?
- 请问如何用delphi打开帮助文件(*.HLP)
- delphi的缺省别名dbdemos怎么不识别?
- TClientDataSet.Locate内存泄漏
- delphi控制网页的定时返回问题?
- 无法收到大富翁的验证信息码
- 我剩不多分了,全给了,快帮帮我
(select * from dan1
union
select * from dan2) a
where 日期>:rq1 and 日期<:rq2 and
货物编号 = 指定货物'
where 货物编号 in
(select * from dan1
union
select * from dan2) a
where a.日期>:rq1 and a.日期<:rq2 and
货物编号 = 指定货物'
if exists(select 1 from sysobjects where name='saletotal_sp' and type='P')
drop proc saletotal_sp
go
CREATE PROC saletotal_sp
@customerno CHAR(8),
@customertypename char(20),
@startdate datetime,
@enddate datetime
as
BEGINif ltrim(rtrim(@customertypename))='' or ltrim(rtrim(@customertypename)) is null
begin
set @customertypename='%'
end
else
begin
set @customertypename=ltrim(rtrim(@customertypename))+'%'
endif @startdate='' or @startdate is null
begin
set @startdate='1900-01-01'
end
if @enddate='' or @enddate is null
begin
set @enddate=getdate()
end----建立出货统计结果表--------------------
create table #saletotalresult(
saleinvno char(10) null, --发票号码
customerno char(8) null , --客户编号
customername char(60) null , --客户名称
customertypename char(20) null, --客户类别名称
date datetime null, --出货日期
totalmoney money not null default 0, --出货金额
curno char(3) null --货币编号
)
insert #saletotalresult
select
saleinvno,
customerno,
(select top 1 customername from customer where customerno=a.customerno) as customername,
(select top 1 customertypename from customertype where customertypeno=(select top 1 customertypeno from customer where customerno=a.customerno)) as customertypename,
date ,
sum(b.qty*b.price) as totalmoney,
b.curno
from
mstc a,dstc b
where (valider is NOT null)
and b.invno=a.invno
group by a.saleinvno,a.customerno,a.date,b.curno
order by a.customerno,a.date
if (ltrim(rtrim(@CUSTOMERNO))='') or (ltrim(rtrim(@CUSTOMERNO)) is null)
begin
select * from #saletotalresult
where customertypename like ltrim(rtrim(@customertypename))
and date between @startdate and @enddate
order by saleinvno,date
end
else
begin
select * from #saletotalresult
where customerno=@customerno
and customertypename like ltrim(rtrim(@customertypename ))
and date between @startdate and @enddate
order by saleinvno,date
end