UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Crosstab Nulls    
 
   
Teddy B
post Jun 13 2011, 03:23 PM
Post #1

UtterAccess Addict
Posts: 195




I have a crosstab query that uses a Count as the Value. Sometimes I get null value in my crosstab query results. Is there any easy way to change my SQL so that my nulls appear as a 0 in my crosstab results?

Here is a simple sample SQL of a crosstab:

TRANSFORM Count([ZooTable].[AnimalNames]) AS ([CountOfAnimalNames])
SELECT [ZooTable].[AnimalTypes]
FROM ZooTable
GROUP BY [Zootable].[AnimalTypes]
PIVOT [ZooTable].[ZooLocation];


Thanks for reading my post! Teddy
Go to the top of the page
 
+
JonSmith
post Jun 13 2011, 03:26 PM
Post #2

UtterAccess Guru
Posts: 594



Replace the field with

IIF(Isnull([ZooTable].[AnimalTypes]),0,[ZooTable].[AnimalTypes])

and it should work
Go to the top of the page
 
+
John Spencer
post Jun 13 2011, 04:00 PM
Post #3

UtterAccess VIP
Posts: 2,445
From: Columbia, Maryland



TRANSFORM CLng(NZ(Count([ZooTable].[AnimalNames]),0)) AS ([CountOfAnimalNames])
SELECT [ZooTable].[AnimalTypes]
FROM ZooTable
GROUP BY [Zootable].[AnimalTypes]
PIVOT [ZooTable].[ZooLocation];
Go to the top of the page
 
+
Teddy B
post Jun 14 2011, 09:23 AM
Post #4

UtterAccess Addict
Posts: 195



Thanks for the reply Guys!

John, I ended up using your solution. Always a pleasure to see your reply on one of my posts!
Go to the top of the page
 
+
JonSmith
post Jun 14 2011, 11:32 AM
Post #5

UtterAccess Guru
Posts: 594



I always forget about the Nz function, Johns was the better solution.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 21st May 2013 - 01:14 PM