本来的表是这样的
库存表 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)
解决方案 »
- Indy10 IdHTTP Get用法求助
- delphi7.0中在关联菜单列表上的与toolbar上的按钮后,按钮上的图标不显示了,而那个没有关联的按钮图标却还是能显示的
- 大家帮帮忙 想个好法子
- 放分200支持menggirl做版主--修罗
- ?能不能用ado控件动态建立数据库?
- 求救:TNMSMTP如何发送邮件???出现“需要SMTP认证”错误怎么解决???
- 有誰用过这样的三层?(无需费神,只谈经验)
- 提一个很简单的问题,谢谢相告。
- 用adoquery的connection设置为adoconnection当把adoconnection的connected:=false后为什么adoquery还可以用?
- 请问如何将图片写入到数据库中?
- 无法收到大富翁的验证信息码
- 我剩不多分了,全给了,快帮帮我
(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