select * from( SELECT row_number() over(PARTITION BY productid ORDER BY sort,Price) as number,* from productattr where flag=false )x WHERE NUMBER=1