-- Aynı ihaledeki teklif talepleri. BaseId açık belgedir: teklif talebinde ihalenin diğer belgeleri, -- satınalma siparişinde kaynak teklifin ihalesindeki bütün belgeler. CREATE OR ALTER VIEW [dbo].[Prc_V_PurchaseRfqAlternative] AS SELECT b.Id AS BaseId, x.Id, x.TenantId, x.RfqNo, x.SupplierId, x.Status, x.SupplierResponse, x.OrderDeadline, x.ExpectedArrival, x.UntaxedAmount, x.TotalAmount, x.CurrencyId, x.IsDeleted FROM Prc_T_PurchaseRfq b INNER JOIN Prc_T_PurchaseRfq x ON x.TenderGroupId = b.TenderGroupId AND x.Id <> b.Id WHERE b.IsDeleted = 0 UNION ALL SELECT o.Id, x.Id, x.TenantId, x.RfqNo, x.SupplierId, x.Status, x.SupplierResponse, x.OrderDeadline, x.ExpectedArrival, x.UntaxedAmount, x.TotalAmount, x.CurrencyId, x.IsDeleted FROM Prc_T_PurchaseOrder o INNER JOIN Prc_T_PurchaseRfq s ON s.Id = o.PurchaseRfqId INNER JOIN Prc_T_PurchaseRfq x ON x.TenderGroupId = s.TenderGroupId WHERE o.IsDeleted = 0