Skip to content

Instantly share code, notes, and snippets.

@gratzc
Last active April 7, 2016 14:19
Show Gist options
  • Save gratzc/6e73df32b9f7d645416ba038ecd33594 to your computer and use it in GitHub Desktop.
Save gratzc/6e73df32b9f7d645416ba038ecd33594 to your computer and use it in GitHub Desktop.
update offerBidderInfo
set bidCount = (select count(*) from ss_bids with (nolock) where offer_id = @offerID and retracted_by_buyer = 'N' and deleted = 'N'),
highBidAmount = b.highBid,
highBidID = b.id,
highBidderID = b.user_id,
proxyBidAmt = b.proxyBidAmount,
bidIncrementAmt = dbo.UDF_CALC_BID_INCREMENT_FROM_OFFERID(@offerID),
updateDate = getdate(),
commission_amt = dbo.udf_calc_commission(@offerID),
transaction_amt = dbo.udf_get_transaction_amount(@offerID, 'F'),
buyer_premium_amt = dbo.udf_calc_buyer_premium(@offerID)
from offerBidderInfo with (nolock)
INNER JOIN ( SELECT top 1 b.ID, b.USER_ID, b.OFFER_ID, b.BID_DATE, b.AMOUNT, b.TERMS, b.WINNING, b.RETRACTED_BY_BUYER, b.DELETED, b.RETRACTED_BY_BUYER_DATE,
b.SOURCE_IP, b.BID_TYPE, b.objectID, b.bestOfferComments, b.bestOfferStatus, b.proxyBidAmount, b.BID_DATE LowBidDate, b.AMOUNT HighBid
FROM SS_BIDS b with (nolock)
WHERE b.OFFER_ID = @offerID and (b.RETRACTED_BY_BUYER <> 'Y') AND (b.DELETED <> 'Y')
ORDER BY b.AMOUNT DESC, b.proxyBidAmount desc, b.OFFER_ID, b.BID_DATE, b.ID) as b
on offerBidderInfo.offerID = b.offer_ID
where offerBidderInfo.offerid = @offerID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment