0

我有两张表,分别是装运和付款表,其中包含以下列

运输

1.Executivename
2.shipername
3.shiperaddress
4.acountno
5.invoiceno 
6.shipdate  
etc.

支付

1.InvoiceNo
2.accountno
3.Date
4.Discount
5.ReceivedAmount 6.MoneyReceiptNo

现在我想用“付款”表的字段按执行名称生成报告。我尝试通过以下存储过程来做到这一点-

CREATE PROCEDURE [dbo].[rptexecutivepayment] @executivename varchar(20) AS 
BEGIN 
    select Executivename,[shipment].accountno,[date],discount,receivedamount,moneyreceiptno
    from shipment 
    full join payment on shipment.accountno=payment.accountno and shipment.invoiceno=payment.invoiceno 
    where Executivename=@executivename order by Executivename 
END
GO

但是,报告 r 生成数据重复。我现在能做什么?请有人帮助我。

4

1 回答 1

0

糟糕的架构...

** 发货表必须有
发货
无发票无其他发货
详情。

**发票表必须有
InvoiceNo
AccountNo otherInvoiceDetails
..

**AccountMaster 表必须有
AccountNo
AccountDetails...

这是一个规范化的模式,不会妨碍你做报告。

于 2012-05-10T22:53:01.557 回答