Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
fshuja
Starting Member
7 Posts |
Posted - 2007-11-30 : 04:44:42
|
| how can i do like thisWith GetAllCategories as ( Select ROW_NUMBER() OVER (Order By [Name] ASC) as Row, Id, ParentCategoryId, [Name], (Select Count(*) From classifieds_Ads Where MemberId=@UserId AND CategoryId=Id AND AdStatus=100)As NumActiveAds From classifieds_Categories)but this is not working as NumActiveAds is returning always zero.Any help?thnks |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2007-11-30 : 04:50:57
|
| Something like this:With GetAllCategories as (Select ROW_NUMBER() OVER (Order By [Name] ASC) as cc.Row, cc.Id, cc.ParentCategoryId, cc.[Name], (Select Count(*) From classifieds_Ads Where MemberId=@UserId AND CategoryId=cc.IdAND AdStatus=100)As NumActiveAdsFrom classifieds_Categories cc) |
 |
|
|
fshuja
Starting Member
7 Posts |
Posted - 2007-11-30 : 05:07:42
|
| thanks a lot it works with a little changeWith GetAllCategories as (Select ROW_NUMBER() OVER (Order By [Name] ASC) asRow, Id, ParentCategoryId, [Name],(Select Count(*) From classifieds_AdsWhere MemberId=@UserId AND CategoryId=cc.IdAND AdStatus=100)As NumActiveAdsFromclassifieds_Categories cc) |
 |
|
|
|
|
|