List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:November 21 2002 2:48am
Subject:Re: question about Sum()
View as plain text  
At 21:38 -0500 11/20/02, Daniel Chicayban wrote:
>Query:
>SELECT Count(id) AS Taken FROM ClassGuests WHERE id=5
>Returns 1 record, value 0
>
>Query:
>SELECT Sum(nGuests) AS Taken FROM ClassGuests WHERE id=5
>Returns 1 record, value '' (nothing)
>
>And
>Query:
>SELECT Count(id)+Sum(nGuests) AS Taken FROM ClassGuests WHERE id=5
>Returns 1 record, value '' (nothing)
>
>I expected to be 0, but it's not. And because of that I need to 
>convert this through code. Is that anyway to force Sum() to return 0 
>if nothing found?
>
>Thanks.
>Daniel

My quess is that you're issuing these queries through some API?
If so, you're probably not getting '' back, but NULL.  And if
*that's* so, you can detect that by checking for whatever value
your API uses to represent NULL.
Thread
question about Sum()Daniel Chicayban21 Nov
  • Re: question about Sum()Paul DuBois21 Nov