Created
March 16, 2015 23:00
-
-
Save qcom/7ec51c3f89a051469d93 to your computer and use it in GitHub Desktop.
why
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from ( | |
select C3.ObjectId, C3.CategoryId, C3.CategorizationId, TheCount, | |
ROW_NUMBER() OVER (ORDER BY C3.ObjectId, C3.CategoryId, C3.Categorizationid desc) as RowNumber | |
from Categorization as C3 right outer join ( | |
select (select Code from Product where ProductId = ObjectId) as Code, C1.ObjectId, C1.CategoryId, ( | |
select count(*) from Categorization as C2 where C2.ObjectId = C1.ObjectId and C2.CategoryId = C1.CategoryId | |
) as TheCount | |
from Categorization as C1 | |
where (select count(*) from Categorization as C2 where C2.ObjectId = C1.ObjectId and C2.CategoryId = C1.CategoryId) > 1 | |
group by C1.CategoryId, C1.ObjectId | |
) as R1 ON C3.ObjectId = R1.ObjectId and C3.CategoryId = R1.CategoryId | |
where C3.ObjectId = 599 | |
) seq where seq.RowNumber between 2 and TheCount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment