select bm.bidMfrName, ba.bidAgencyName, b.bidName, b.dateCreated, bl.bidLineNumber, bl.bidLineDescription, bs.bidSku, bs.bidSkuDesc, blp.priceDeliveredRate, blp.priceFobRate, blp.priceBillBackRate, blp.priceOffInvoiceRate, pl.priceListCode, pl.priceListDesc, pl.dateCreated, plp.deliveredRate, plp.fobRate, plp.billBackRate, plp.offInvoiceRate from tbl_BID_Bids b inner join tbl_BID_BidLines bl on bl.bidId = b.bidId and bl.ownerId = b.ownerId and bl.ownerType = b.ownerType inner join tbl_BID_BidLineProducts blp on blp.bidLineId = bl.bidLineId and blp.ownerId = bl.ownerId and blp.ownerType = bl.ownerType inner join tbl_BID_Skus bs on bs.bidSkuId = blp.bidSkuId and bs.ownerId = blp.ownerId and bs.ownerType = blp.ownerType inner join tbl_BID_Manufacturers bm on bm.bidMfrId = bs.bidMfrId and bm.ownerId = bs.ownerId and bm.ownerType = bs.ownerType inner join tbl_BID_PriceLists pl on pl.priceListId = blp.priceListId and pl.ownerId = blp.ownerId and pl.ownerType = blp.ownerType inner join tbl_BID_PriceListPrices plp on plp.priceListId = pl.priceListId and plp.bidSkuId = bs.bidSkuId and plp.ownerId = bs.ownerId and plp.ownerType = bs.ownerType inner join tbl_BID_Agencies ba on ba.bidAgencyId = b.bidAgencyId where b.ownerId = 387 and b.ownerType = 'BRO' and b.deleted = 'N' and b.archive = 'N' and b.dateCreated > '2016-01-01 00:00:00.000' -- since Jan 1st 2016 and pl.dateCreated > '2016-01-01 00:00:00.000' -- since the earliest blanket price created this year and ( blp.priceListId is not null or blp.priceListId <> 0 ) and blp.priceListId in ( select distinct plo.priceListId from tbl_BID_PriceListsOverride plo where plo.ownerId = 387 and plo.ownerType = 'BRO' group by plo.priceListId --having ( select COUNT(*) from tbl_BID_PriceListsOverride ploA where ploA.priceListId = plo.priceListId and ploA.overrideYN = 'Y' ) = 0 )