Crosstab Query Null Values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I do a cross tab query it gives me a null if a record does not exist.

How do I change the Null to 0

Thanks in advance

Trevor
 
Check the posting from about 5 hours earlier with a subject "How do I
replace null values in crosstab queries?"

You might want to do a quick search of posts prior to submitting your
question. It is usually much quicker.
 
Switch the crosstab from design to SQL View (View menu).

Add Nz() around the expression in the first line, e.g. change:
TRANSFORM Sum(tblInvoiceDetail.Quantity) AS SumOfQuantity
to:
TRANSFORM Nz(Sum(tblInvoiceDetail.Quantity), 0) AS SumOfQuantity
 
I have the same problem but also need to know how to get rid of an extra
column that has a "<>" at the top of it.

Thanks
 
The <> column represents null values.
You can remove them from the query by specifing:
Is Not Null
in the Criteria row under the Column Heading field.
 
Unfortunately, due to the nature of my query I can't access the design view
to try what you suggested.

I have therefore added "WHERE [Queryfour.Severity/Closure] IS NOT NULL" but
this means that the first row is not displayed when there are no records
present.

Any ideas?


TRANSFORM NZ(Count(Queryfour.DefectID),0) AS CountOfDefectID
SELECT Intervals.Descr AS Range, Count(Queryfour.DefectID) AS Total
FROM Queryfour RIGHT JOIN Intervals ON (Queryfour.VarAge <= Intervals.High)
AND (Queryfour.VarAge >= Intervals.Low)
WHERE [Queryfour.Severity/Closure] IS NOT NULL
GROUP BY Intervals.Descr
PIVOT [Queryfour.Severity/Closure];
 
The other option would be to add an IN to the Pivot clause, and list the
valid values, e.g.:
PIVOT [Queryfour.Severity/Closure] In (1,2,3,4);

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Andibevan said:
Unfortunately, due to the nature of my query I can't access the design
view
to try what you suggested.

I have therefore added "WHERE [Queryfour.Severity/Closure] IS NOT NULL"
but
this means that the first row is not displayed when there are no records
present.

Any ideas?


TRANSFORM NZ(Count(Queryfour.DefectID),0) AS CountOfDefectID
SELECT Intervals.Descr AS Range, Count(Queryfour.DefectID) AS Total
FROM Queryfour RIGHT JOIN Intervals ON (Queryfour.VarAge <=
Intervals.High)
AND (Queryfour.VarAge >= Intervals.Low)
WHERE [Queryfour.Severity/Closure] IS NOT NULL
GROUP BY Intervals.Descr
PIVOT [Queryfour.Severity/Closure];

Allen Browne said:
The <> column represents null values.
You can remove them from the query by specifing:
Is Not Null
in the Criteria row under the Column Heading field.
 
Thankyou Soooo much - that's fantastic - works a dream.

:-)

Allen Browne said:
The other option would be to add an IN to the Pivot clause, and list the
valid values, e.g.:
PIVOT [Queryfour.Severity/Closure] In (1,2,3,4);

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Andibevan said:
Unfortunately, due to the nature of my query I can't access the design
view
to try what you suggested.

I have therefore added "WHERE [Queryfour.Severity/Closure] IS NOT NULL"
but
this means that the first row is not displayed when there are no records
present.

Any ideas?


TRANSFORM NZ(Count(Queryfour.DefectID),0) AS CountOfDefectID
SELECT Intervals.Descr AS Range, Count(Queryfour.DefectID) AS Total
FROM Queryfour RIGHT JOIN Intervals ON (Queryfour.VarAge <=
Intervals.High)
AND (Queryfour.VarAge >= Intervals.Low)
WHERE [Queryfour.Severity/Closure] IS NOT NULL
GROUP BY Intervals.Descr
PIVOT [Queryfour.Severity/Closure];

Allen Browne said:
The <> column represents null values.
You can remove them from the query by specifing:
Is Not Null
in the Criteria row under the Column Heading field.

I have the same problem but also need to know how to get rid of an extra
column that has a "<>" at the top of it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top