My Assistant
![]() ![]() |
|
|
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 |
|
|
|
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 |
|
|
|
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]; |
|
|
|
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! |
|
|
|
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 Top · Lo-Fi Version | Time is now: 21st May 2013 - 01:14 PM |