I am using SQL Server 2005
I have user ID and gender with user The table is I want to select the Top 1000 Men (0) and Top 1000 Male (1) Orders by User ID.
If I create a union then only one result set is ordered by the userID desc what is the other way to do this?
Select from top 1000 * users where gender = 0 union Select from top 1000 * users gender = 1 command userID desc
Another way to do this is with
as the top user (SELECT UserId, Gender, ROW_NUMBER () Users are part of the Gender Order by DESC) where the gender (0,1) from RN / * I think this line may not be required * /) SELECT UserId, TopUsers with gender WHERE RN & lt; = 1000 ORDER BY UserID DESC
Comments
Post a Comment