ник: osmor
И мне тоже помогите, у меня тоже не работает
SELECT tblWayBill.WayBillNum AS WayBillNum, tblWayBill.WayBillDate AS WayBillDate, 'DTS' AS Imj_post, '3267' AS K_fpst, 0 AS Tarif_pr,
0 AS Ndc_tf, 0 AS Stm_proch,
(SELECT COUNT('*')
FROM tblWayBillDetail wbN
WHERE wbN.WayBillDetailId <= wb.WayBillDetailId AND wbn.WayBillID = wb.WayBillID) AS N_stroki, tblBill.BillContract AS N_kontr,
'' AS D_kontr, tblProducts.ProductName AS ProductName, wb.ProductID AS ProductID, tblUnits.UnitShort AS Imj_izm,
tblProducts.ProductProducer AS ProductProducer, wb.EXP AS D_gdn, dbo.fnGetCertificateNum(tblCertificate.cerID) AS cerNum,
tblCertificate.cerIssueDate AS cerIssueDate, tblCertificate.cerIssued AS cerIssued, tblCertificate.cerID AS cerID, tblCertificate.cerTerm AS cerTerm,
0 AS N_sert, '' AS D_sert, wb.WayBillQty AS WayBillQty, 0 AS St_upak, 0 AS KolStUpak, 0 AS Pr_upak, 0 AS KolPrUpak,
tblProducts.ProductPriceState AS Cena_o, (wb.WayBillPrice / (1 + tblProducts.ProductNDS) - tblProducts.ProductPriceState)
/ tblProducts.ProductPriceState AS Nacen_pst, wb.WayBillPrice / (1 + tblProducts.ProductNDS) AS WayBillPriceWONDS,
wb.WayBillPrice AS WayBillPrice, wb.WayBillPrice * wb.WayBillQty / 1.1 AS [Sum], wb.WayBillPrice * wb.WayBillQty AS Sumsnds,
wb.WayBillPrice * wb.WayBillQty - wb.WayBillPrice * wb.WayBillQty / 1.1 AS Sum_nds, tblWayBill.WayBillID AS WayBillID,
tblCertificate.cerIssuer AS cerIssuer, tblCertificate.cerPassportNum AS cerPassportNum, tblCertificate.cerPassportDate AS cerPassportDate,
wb.WayBillDetailID AS WayBillDetailID, tblWayBill.WayBillCustomer AS WayBillCustomer, tblCustomers.CustomerName AS CustomerName,
tblProducts.ProductNDS AS ProductNDS, tblIncome.IncomeCustomer AS IncomeCustomer, IncomeProvider.CustomerName AS IncomeCustomerName,
tblIncomeDetail.IncomeBatch AS IncomeBatch, tblIncomeDetail.IncomeDetailGTD AS IncomeDetailGTD, tblCertificate.cerHolder AS cerHolder
FROM tblWayBill INNER JOIN
tblWayBillDetail wb ON tblWayBill.WayBillID = wb.WayBillID INNER JOIN
tblProducts WITH (nolock) ON wb.ProductID = tblProducts.ProductID INNER JOIN
tblBill WITH (nolock) ON tblWayBill.WayBillBillID = tblBill.BillID INNER JOIN
tblUnits WITH (nolock) ON tblProducts.ProductUnit = tblUnits.UnitID INNER JOIN
tblIncomeDetail WITH (nolock) ON wb.IncomeProductID = tblIncomeDetail.IncomeProductID INNER JOIN
tblIncome WITH (nolock) ON tblIncomeDetail.IncomeID = tblIncome.IncomeID INNER JOIN
tblCustomers ON tblWayBill.WayBillCustomer = tblCustomers.CustomerID INNER JOIN
tblCustomers IncomeProvider ON tblIncome.IncomeCustomer = IncomeProvider.CustomerID LEFT OUTER JOIN
tblCertificate WITH (nolock) ON wb.ProductID = tblCertificate.cerProduct AND wb.IncomeBatch = tblCertificate.cerIncomeBatch
WHERE (tblWayBill.WayBillID = [idWayBill])
ORDER BY wb.WayBillDetailID