UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> sum column while skipping over rows that are not numeric    
 
   
pliuCEP
post Aug 8 2007, 03:54 PM
Post #1

New Member
Posts: 11



In Access, is it possible to write a query that sums up a column, but skips over rows that are not numeric so that it does not return a datatype mismatch error?

Thank you.
Go to the top of the page
 
+
theDBguy
post Aug 8 2007, 04:22 PM
Post #2

Access Wiki and Forums Moderator
Posts: 48,113
From: SoCal, USA



You will need to create a query that eliminates those records first before doing the Totals query. HTH.
Go to the top of the page
 
+
Ender
post Aug 8 2007, 05:48 PM
Post #3

UtterAccess VIP
Posts: 1,283
From: AZ



theDBguy is right and this is one way you might do that...

select sum(field)
from table
where isnumeric(field) = true
Go to the top of the page
 
+
balaji
post Aug 9 2007, 08:53 AM
Post #4

UtterAccess VIP
Posts: 5,635
From: Chicagoland, USA



Or you can use iif() to skip over just the values in that field without eliminating that record entirely if different fields will have null in different records. Like below:

select sum(iif(isnumeric(field), field,0)) as sumoffield, sum(iif(isnumeric(field1), field1,0)) as sumoffield1 from table
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 06:22 AM