| SQL |
select b.ownerId, b.ownerType, opr.operatorId, opr.companyName, opr.address, opr.city, opr.state, opr.zipCode
, b.bidName, b.bidNumber, b.bidOpeningDateTime, b.deliveryStartDate, b.deliveryEndDate, bl.bidLineNumber, bl.bidLineDescription,
s.sku, pkg.scc14 as GTIN, pkg.upc as UPC, s.skuDesc, s.packSizeDesc, s.skuId,
bl.bidLineQtyAmt, bl.bidLineQtyUM, blp.termsOfGuarantee, blp.termsOfAllowance, blp.priceUM, blp.priceDeliveredRate, blp.priceFOBRate, blp.priceBillbackRate, blp.priceOffInvoiceRate
, blp.bidLineProductStatus, blp.bidLineProductStatus2, blp.bidLineProductId, bl.bidLineId, bl.bidId,
b.internalContactId,
ac.firstname agencyFirstName, ac.lastName agencyLastName, ac.email agencyEmail, ac.title agencyTitle, ac.phone agencyPhone, ac.phoneExt agencyPhoneExt, ac.fax agencyFax,
mc.firstname mfrFirstName, mc.lastName mfrLastName, mc.email mfrEmail, mc.title mfrTitle, mc.phone mfrPhone, mc.phoneExt mfrPhoneExt, mc.fax mfrFax,
b.releaseDate, b.bidOpeningDateTime, b.expectedAwardDate,
b.bidAgencyId, m.bidMfrId, opr.fsl_choId
from tbl_BID_Manufacturers m with (nolock)
inner join tbl_BID_BidManufacturers bm with (nolock)
on bm.bidMfrId = m.bidMfrId
and bm.ownerId= m.ownerId
and bm.ownerType = m.ownertype
inner join tbl_BID_Bids b with (nolock)
on b.bidId = bm.bidId
and b.ownerId = bm.ownerId
and b.ownerType = bm.ownerType
inner join tbl_BID_BidLines bl with (nolock)
on bl.bidId = b.bidId
and bl.ownerId = b.ownerId
and bl.ownerType = b.ownerType
inner join tbl_BID_SKus bs with (nolock)
on bs.bidMfrId = m.bidMfrId
and bs.ownerId = m.ownerId
and bs.ownerType = m.ownerType
inner join tbl_BID_BidLineProducts blp with (nolock)
on blp.bidSkuId = bs.bidSkuId
and blp.bidLineId = bl.bidLineId
and blp.ownerId = bs.ownerId
and blp.ownerType = bs.ownerType
inner join tbl_PRD_Skus s with (nolock)
on s.skuId = bs.skuId
and s.ownerId = bs.ownerId
and s.fsl_tablecode = bs.ownertype
left outer join tbl_PRD_Packaging pkg with (nolock)
on pkg.ownerId = s.ownerId
and pkg.fsl_tablecode = s.fsl_tablecode
and pkg.linkId = s.skuId
and pkg.linkType = 'SKU'
inner join tbl_BID_Agencies a with (nolock)
on a.ownerId = b.ownerId
and a.ownerType = b.ownerType
and a.bidAgencyId = b.bidAgencyId
inner join tbl_OPR_ClientOperators opr with (nolock)
on opr.operatorId = a.partnerId
and opr.ownerId = a.ownerId
and opr.fsltablecode = a.ownertype
left outer join tbl_BID_PartnerContacts ac
on ac.ownerId = b.ownerId
and ac.ownertype = b.ownerType
and ac.bidPartnerType = 'A'
and ac.bidPartnerId = a.bidAgencyId
and ac.bidContactId = a.bidAgencyContactId
left outer join tbl_BID_PartnerContacts mc
on ac.ownerId = b.ownerId
and mc.ownertype = b.ownerType
and mc.bidPartnerType = 'M'
and mc.bidPartnerId = m.bidMFRId
and mc.bidContactId = m.bidMFRContactId
where m.mfrId = ?
and m.ownerId = ?
and m.ownerType = 'BRO'
and a.partnerType = 'OPR'
and b.bidId = ?
order by opr.companyName, bidName, bidNumber, deliveryEndDate desc |