Re: Help with Subquery
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 23 Apr 2008 21:21:29 +0200
On Mon, 21 Apr 2008 02:09:00 -0700, Access To Access wrote:
(snip)
COUNT(ISNULL(cmp_HiddenHearingOverall.LastCRC, 0))
Hi Access To Access,
This might be the problem. The COUNT function will count the number of
non-NULL values. The ISNULL converts NULL (a NULL value) to 0 (a
non-NULL value). If you want to count the number of rows in the result
where LastCRC is not NULL, all you have to do is to remove the ISNULL.
If, on the other hand, you want to count the number of rows where this
is NULL (you might be confused with Access' function IsNull, which is a
Boolean that returns True if the argument is NULL), then you shoould use
SUM(CASE WHEN blahblah.LastCRC IS NULL THEN 1 ELSE 0 END)
If this is not it, then you should provide more details: structure of
the tables involved (posted as CREATE TABLE statements, including all
constraints, propertiies, and indexes; you may omit irrelevant columns
though), sample data (as a series of INSERT statements so that I can
easily recreate the sample data on my test DB), and expected results.
See www.aspfaq.com/5006 for more information.
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
.
- References:
- Help with Subquery
- From: Access To Access
- Help with Subquery
- Prev by Date: Re: Hopefully a basic query question
- Next by Date: auto lenght
- Previous by thread: Help with Subquery
- Next by thread: auto lenght
- Index(es):
Relevant Pages
|
|