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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing #Error with a number

Status
Not open for further replies.
Jul 4, 2004
42
0
0
GB
Hello.

Running the following code delivers the required results unless [qry Staff Task Volumes.[sumofvolumes] is "0".

This is due to [ActualMinsPersTask] divides [sumofvolume]/[sumoftime] and if [sumofvolumes] = "0" you cant divide the [sumofvolumes] figure by "0", you get an #error in [ActualMinsPerTask].

SELECT [qry Staff Actual Rate Child].[Staff Number], [qry Staff Actual Rate Child].[Task Code], [qry Staff Actual Rate Child].SumOfTime, [qry Staff Task Volumes].SumOfVolumes, [sumoftime]/[SumOfVolumes] AS ActualMinsPerTask
FROM [qry Staff Actual Rate Child] INNER JOIN [qry Staff Task Volumes] ON [qry Staff Actual Rate Child].[Task Code] = [qry Staff Task Volumes].[Task Code];


Thanks in advance for your help.
 
Code:
[COLOR=blue]SELECT[/color] [qry Staff Actual Rate Child].[Staff [COLOR=blue]Number[/color]],
       [qry Staff Actual Rate Child].[[COLOR=#FF00FF]Task[/color] Code],
       [qry Staff Actual Rate Child].SumOfTime,
       [qry Staff [COLOR=#FF00FF]Task[/color] Volumes].SumOfVolumes,
       [COLOR=blue]CASE[/color] [COLOR=blue]WHEN[/color] SumOfVolumes = 0
            [COLOR=blue]THEN[/color] 0
            [COLOR=blue]ELSE[/color][sumoftime]/[SumOfVolumes] [COLOR=blue]END[/color]
            [COLOR=blue]AS[/color] ActualMinsPerTask
[COLOR=blue]FROM[/color] [qry Staff Actual Rate Child]
     [COLOR=blue]INNER[/color] [COLOR=blue]JOIN[/color] [qry Staff [COLOR=#FF00FF]Task[/color] Volumes] [COLOR=blue]ON[/color]
           [qry Staff Actual Rate Child].[[COLOR=#FF00FF]Task[/color] Code] =
           [qry Staff [COLOR=#FF00FF]Task[/color] Volumes].[[COLOR=#FF00FF]Task[/color] Code]

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top