|
i am trying to write a query that would do the following on the view update_winnerlist which is already GROUPed BY item_index SELECT email_id (SELECT email_id,min(bid_amount) FROM update_winnerslist AS a1 WHERE a1.item_index = 10 ) i need to perform the above in a single query as i am using it in a trigger to update a table.
(comments are locked)
|
|
@heboy1908 I did not understand your requirement properly. But if you want to hit your table only once then the following could be what you want Moreover, please keep in mind that there could be ties for the bid amount and if you are doing it in the trigger, you may need to get a random choice or whatever the requirement is. For that the TOP clause may be helpful. PS: RANK() function could be used as well instead of ROW_NUMBER()
(comments are locked)
|


the update_winnerslist table contains mail_id,item_index,bid_amount attributes.The table is already grouped by item_index values. I am trying to get the email_id for item_index=10 with the lowest bid_amount i.e. the email_id of the person who made the lowest bid on item_index 10.