In the ORDER BY clause we have to use CASE statement to achieve result. We can add more case statement if we have more than one rows to treat differently.
In this following diagram you can notice that there are two rows which are with ProductID 712 and 715. Now our final requirement is that we want row 715 to be the second last row in the resultset and 712 as a very last row in the resultset.
Here is the script…
SELECT [ProductID], COUNT(*) CountofProductID
WHERE ProductID BETWEEN 707 AND 716
GROUP BY [ProductID]
ORDER BY CASE WHEN [ProductID] = 715 THEN 1
WHEN [ProductID] = 712 THEN 2 ELSE 0 END