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 |
|
mike1973
Starting Member
46 Posts |
Posted - 2011-11-15 : 05:06:43
|
| Hello friends,i have this query it should return the max value for the billnumberSELECT MAX(BillNUmber) as MAXNUBMRFROM BillsWHERE ClientID=@ClientID and Hidden=0the problem is how to i replace the returned NULL value with a 0?Thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-11-15 : 05:12:48
|
| SELECT ISNULL(MAX(BillNUmber),0) as MAXNUBMRFROM BillsWHERE ClientID=@ClientID and Hidden=0MadhivananFailing to plan is Planning to fail |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2011-11-15 : 14:22:02
|
You can SELECT ISNULL(MAX(BillNUmber),0) as MAXNUBMRFROM BillsWHERE ClientID=@ClientID and Hidden=0or you canAs Madhivanan has shown you can use the ISNULL function. There is also the COALESCE function, which I beleive is ANSI 99 compliant, if that matters:please mark this answer as accepted if it helped you!(yea, i miss the guy, just picking up the slack )http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|