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 |
|
theonlylawislove
Starting Member
7 Posts |
Posted - 2008-04-01 : 19:34:52
|
| [code]SELECT Name, TagID, (SELECT COUNT(TagID) AS Expr1 FROM dbo.mw_PagesTagMap WHERE (TagID = tag.TagID)) AS TagWeightFROM dbo.mw_Tags AS tag[/code]This query works exactly how I want it to.I would like to modify this to NOT return any column that has a TagWeight of 0[code]SELECT Name, TagID, (SELECT COUNT(TagID) AS Expr1 FROM dbo.mw_PagesTagMap WHERE (TagID = tag.TagID)) AS TagWeightFROM dbo.mw_Tags AS tagWHERE (TagWeight <> 0)[/code]I thought this would do it but I'm getting an error "invalied column TagWeight".How would I get this to work? |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-01 : 19:51:40
|
| SELECT Name, TagID, (SELECT COUNT(TagID) AS Expr1 FROM dbo.mw_PagesTagMap WHERE (TagID = tag.TagID) Having count(TagID)>=1) AS TagWeightFROM dbo.mw_Tags AS tag |
 |
|
|
theonlylawislove
Starting Member
7 Posts |
Posted - 2008-04-01 : 23:37:43
|
quote: Originally posted by sodeep SELECT Name, TagID, (SELECT COUNT(TagID) AS Expr1 FROM dbo.mw_PagesTagMap WHERE (TagID = tag.TagID) Having count(TagID)>=1) AS TagWeightFROM dbo.mw_Tags AS tag
note quite...This query still returns that Tag that is used more than once, this time with a null value.I'm looking to ONLY SELECT THE TAGS THAT ARE USED.Thanks! |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-01 : 23:54:29
|
| SELECT Name, TagID,(SELECT COUNT(TagID) AS Expr1FROM dbo.mw_PagesTagMapWHERE (TagID = tag.TagID)and tag.TagID is not nullHaving count(TagID)>=1) AS TagWeightFROM dbo.mw_Tags AS tag |
 |
|
|
|
|
|