I am using MS SQL Server.
I have a single table [Items] the fields are as follows:
I need a stored procedure that pulls all items that have an [ItemRating] of 3 (this is really a parameter @ItemRating) or if they don't have an [ItemRating] of 3 I need to see if they have an [ItemRating] of 2 IF and only if they have the same [DisplayCategory]. And-so-on 2 to 1 and 1 to 0(ONLY IF THEY HAVE THE SAME [DisplayCategory])
So in short it would select the highest [ItemRating] per [DisplayCategory] that was not greater than the @ItemRating parameter.