select b.bidId, b.bidName, b.bidNumber, min( bl.sampleDeliveryDateTime ) sampleDeliveryDateTime
from tbl_BID_Bids b with (nolock)
inner join tbl_BID_BidLines bl with (nolock)
on bl.ownerId = b.ownerId
and bl.ownerType = b.ownerType
and bl.bidId = b.bidId
inner join tbl_BID_Agencies ba with (nolock)
on ba.ownerId = b.ownerId
and ba.ownerType = b.ownerType
and ba.bidAgencyId = b.bidAgencyId
inner join tbl_OPR_ClientOperators opr with (nolock)
on opr.ownerId = ba.ownerId
and opr.fsltablecode = ba.ownerType
and opr.operatorId = ba.partnerId
and ba.partnerType = 'OPR'
and opr.territoryId in ( )
left outer join tbl_BID_BidLineProducts blp with (nolock)
on blp.ownerId = bl.ownerId
and blp.ownerType = bl.ownerType
and blp.bidLineId = bl.bidLineId
where b.ownerId =
and b.ownerType =
and b.archive = 'N'
and b.deleted = 'N'
and bl.sampleRequired = 'Y'
--and coalesce( blp.sampleDelivered, 'N' ) = 'N'
AND ( blp.sampleDelivered = 'N' OR blp.sampleDelivered IS NULL )
group by b.bidId, b.bidName, b.bidNumber
select bidId
from tbl_BID_Bids
where sourceBidId =
and ownerId =
and ownerType =
and deleted = 'N'
--->
Bid #
By Date
select * from qmd_bidAlerts
order by alertDate desc, bidNumber