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 |
|
Babli
Yak Posting Veteran
53 Posts |
Posted - 2007-04-27 : 03:16:00
|
| Hi,I have a table with 2 columns namelyWeb,UserNamein my Stored Procedure I saySelect fnGetPage(Web) as Page,Count(Web) as Cnt,UserName from tableWhen Count(Web) is 0 I want an empty result only when it is greater than 0 I want a result.How can i apply this condition. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-27 : 03:19:09
|
| select page, cnt, username from (Select fnGetPage(Web) as Page,Count(Web) as Cnt,UserName from table) as awhere page > 0Peter LarssonHelsingborg, Sweden |
 |
|
|
Babli
Yak Posting Veteran
53 Posts |
Posted - 2007-04-27 : 03:21:25
|
I was wondering if there is a way to put an IF condition while selecting the column.If not I have go for subquery like how u suggested.quote: Originally posted by Peso select page, cnt, username from (Select fnGetPage(Web) as Page,Count(Web) as Cnt,UserName from table) as awhere page > 0Peter LarssonHelsingborg, Sweden
|
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-04-27 : 11:36:50
|
| Then you can remove the WHERE condition in your query. What do you mean by empty result set? Dinakar NethiSQL Server MVP************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-27 : 12:06:44
|
| [code]Select fnGetPage(Web) as Page,Count(Web) as Cnt,UserName from tablegroup by Web, UserNamehaving Count(Web) > 0[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|
|
|