Nz - need code -

B

Bibi

I have a crosstab query that yields no value where I need a 0 value for
further calculation.

I do not write code:
This is the SQL for the crosstab.

TRANSFORM Sum(qLeaseEndDataAllDatesStatusJoin.Count) AS SumOfCount
SELECT qLeaseEndDataAllDatesStatusJoin.[Lease Month],
qLeaseEndDataAllDatesStatusJoin.[Lease Year],
Sum(qLeaseEndDataAllDatesStatusJoin.Count) AS [Total Of Count]
FROM qLeaseEndDataAllDatesStatusJoin
GROUP BY qLeaseEndDataAllDatesStatusJoin.[Lease Month],
qLeaseEndDataAllDatesStatusJoin.[Lease Year]
PIVOT qLeaseEndDataAllDatesStatusJoin.Status;

I'm pretty sure I need to add an Nz somewhere - just don't know
where......could someone please help?
 
D

Duane Hookom

Try:
TRANSFORM Val(Nz(Sum(qLeaseEndDataAllDatesStatusJoin.Count),0)) AS
SumOfCount
SELECT qLeaseEndDataAllDatesStatusJoin.[Lease Month],
qLeaseEndDataAllDatesStatusJoin.[Lease Year],
Sum(qLeaseEndDataAllDatesStatusJoin.Count) AS [Total Of Count]
FROM qLeaseEndDataAllDatesStatusJoin
GROUP BY qLeaseEndDataAllDatesStatusJoin.[Lease Month],
qLeaseEndDataAllDatesStatusJoin.[Lease Year]
PIVOT qLeaseEndDataAllDatesStatusJoin.Status;
 
B

Bibi

Thank you so much! I was really struggling with this.

TIA
Bibi


Duane Hookom said:
Try:
TRANSFORM Val(Nz(Sum(qLeaseEndDataAllDatesStatusJoin.Count),0)) AS
SumOfCount
SELECT qLeaseEndDataAllDatesStatusJoin.[Lease Month],
qLeaseEndDataAllDatesStatusJoin.[Lease Year],
Sum(qLeaseEndDataAllDatesStatusJoin.Count) AS [Total Of Count]
FROM qLeaseEndDataAllDatesStatusJoin
GROUP BY qLeaseEndDataAllDatesStatusJoin.[Lease Month],
qLeaseEndDataAllDatesStatusJoin.[Lease Year]
PIVOT qLeaseEndDataAllDatesStatusJoin.Status;

--
Duane Hookom
MS Access MVP

Bibi said:
I have a crosstab query that yields no value where I need a 0 value for
further calculation.

I do not write code:
This is the SQL for the crosstab.

TRANSFORM Sum(qLeaseEndDataAllDatesStatusJoin.Count) AS SumOfCount
SELECT qLeaseEndDataAllDatesStatusJoin.[Lease Month],
qLeaseEndDataAllDatesStatusJoin.[Lease Year],
Sum(qLeaseEndDataAllDatesStatusJoin.Count) AS [Total Of Count]
FROM qLeaseEndDataAllDatesStatusJoin
GROUP BY qLeaseEndDataAllDatesStatusJoin.[Lease Month],
qLeaseEndDataAllDatesStatusJoin.[Lease Year]
PIVOT qLeaseEndDataAllDatesStatusJoin.Status;

I'm pretty sure I need to add an Nz somewhere - just don't know
where......could someone please help?
 

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

Top