Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query to report 3 decimals 1

Status
Not open for further replies.

williekay

Technical User
Jun 30, 2003
121
US
I got this query. I got into the properties of the %forNULL field, set it 3 decimals, set it to percent. What is happing is this the sum of is 75, so 100-75 is 25. The NULLS of is 2, so 25/2 is 12.5. I'm getting 12 ?????


SELECT [Samples1].[Lot No], Sum(IIf(IsNull(),1,0))/(100-Sum()) AS [%forNULL]
FROM Samples1
WHERE (((Left([Lot No],2))="`¥"))
GROUP BY [Samples1].[Lot No];


Willie
 
How are ya williekay . . . . .

Try:
Code:
[blue]SELECT [Samples1].[Lot No], Format(Sum(IIf(IsNull([S]),1,0))/(100-Sum([S])),"#,##0.000") AS [%forNULL][/blue]

Calvin.gif
See Ya! . . . . . .
 
Something else is happening, I'll have to investigate, this worked, but I'm still getting .120 instead of .125 ??

Willie
 
williekay . . . . .

What you show is a [purple]Percision[/purple] problem. I've added conversion to [purple]Double Percision[/purple] for the result, if this doesn't work you'll have to add the conversion to other parts of the arithmetic. Try:
Code:
[blue]SELECT [Samples1].[Lot No], Format([purple][b]CDbl([/b][/purple]Sum(IIf(IsNull([S]),1,0))/(100-Sum([S]))[purple][b])[/b][/purple],"#,##0.000") AS [%forNULL][/blue]
Or
Code:
[blue]SELECT [Samples1].[Lot No], Format([purple][b]CDbl([/b][/purple]Sum(IIf(IsNull([S]),[purple][b]CDbl([/b][/purple]1[purple][b])[/b][/purple],0))/(100-Sum([S]))[purple][b])[/b][/purple],"#,##0.000") AS [%forNULL][/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top