Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 9th, 2006, 05:26 PM
Registered User
Join Date: Mar 2006
Location: Irvine, CA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default syntax of sum in SQL

I'm trying to find the summation of a column called Total_Months in
Access. In the sql, I type in:
( SELECT Sum([dbo_tblPermits].Total_Months) FROM [dbo_tblPermits] WHERE
(dbo_tblPermits.PermitNo LIKE 'AR%')) AS mySum

In addition, dbo_tblPermits is the name of my table and PermitNo is the
various kinds of permits that I have.
However, I get an inaccurate answer. Then I tried the DSum formula which is:
( SELECT DSum("Total_Months", "dbo_tblPermits", "dbo_tblPermits.PermitNo
LIKE 'AR%'") )AS myDSum
However, I get a syntax error. I've been looking at my code for the past
two days, but I'm not getting anywhere.

  #2 (permalink)  
Old March 10th, 2006, 03:17 AM
Authorized User
Join Date: Mar 2006
Location: Bratislava, , Slovakia.
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts

Try this:

SELECT Sum(Total_Months) AS mySum FROM dbo_tblPermits WHERE
PermitNo LIKE 'AR%'


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I in SQL group by week & sum the values (i.e. callagga SQL Language 2 May 16th, 2008 07:25 AM
using union all syntax with sum function fdtoo SQL Server 2000 3 July 27th, 2006 02:31 PM
syntax of sum in SQL heghtera SQL Language 1 March 13th, 2006 09:23 AM
SELECT SUM syntax... Anubis Access VBA 8 December 15th, 2003 08:04 PM
SQL Syntax jeffg22 SQL Language 6 July 28th, 2003 06:41 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.