以下查询从多个表中检索数据。
存在一个问题,因为数据增加了检索数据的时间也增加了(行数达到了2万,显示结果需要花费超过一分钟)。
我使用过存储过程,但结果是一样的。任何解决方案?
Select TransactionDate,
T.InvoiceNo,
T.TotalAmount,
PCost.TotalCostPrice ,
(T.TotalAmount - PCost.TotalCostPrice) as TProfit,
P.PaidAmount, P.Balance,
CONCAT(Lastname, ', ', Firstname, ' ', Middlename) as Cashier,
ISNULL(P.DiscountAmount,0),
ISNULL(P.ProfitAmount,0),
CustomerInfo
FROM [Transaction] T
INNER JOIN TransactionPayment P ON T.InvoiceNo = P.InvoiceNo
INNER JOIN Employee E ON T.EmployeeID = E.EmployeeID
LEFT OUTER JOIN (
SELECT SUM(p.CostPrice*tl.Quantity) as TotalCostPrice,
tl.InvoiceNo
FROM Product p
INNER JOIN TransactionLineItem tl ON p.ProductID = tl.ProductID
INNER JOIN [Transaction] T ON T.InvoiceNo = tl.InvoiceNo
WHERE TransactionDate >= @DateFrom AND TransactionDate <= @DateTo
GROUP BY tl.InvoiceNo
) as PCost ON PCost.InvoiceNo = T.InvoiceNo
WHERE TransactionDate >= @DateFrom AND TransactionDate <= @DateTo
答案 0 :(得分:0)
试试这个:
Microsoft.Office.Interop.Word.Paragraph para1 = document.Content.Paragraphs.Add(ref missing);
Microsoft.Office.Interop.Word.Paragraph para2 = document.Content.Paragraphs.Add(ref missing);