Results 1 to 7 of 7
  1. #1
    txacoli is offline Novice
    Windows Vista Access 2007
    Join Date
    Nov 2010
    Posts
    19

    A very simple query re totals........

    At work, we time when our referrals come in and at the end of the year, we have to produce charts to show things like this. The query I've developed shows me how many referrals we get between each hour block (e.g. 07.00 - 07.59) which is fine, but I would also like it to total up the grand total of referrals at the bottom of that column.

    Basically, this is my code (don't laugh, I'm a total newbie and it's very basic).

    SELECT [Referrals 2010].Assess, Count(*) AS [Number], [Referrals 2010].Time
    FROM [Referrals 2010]
    GROUP BY [Referrals 2010].Assess, [Referrals 2010].Time


    HAVING ((([Referrals 2010].Assess)="No") AND (([Referrals 2010].Time) Between "07.00-07.59" And "19.00-19.59"));

    I can add an autosum into my 2007 Access at home, but not on the 2003 Access I'm running at work. Can someone tell me how to make it do this simple little thing please?

    Many thanks in advance

    Mark

  2. #2
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    Might be an idea to look at the DSUM() and SUM() functions.

    Good luck

  3. #3
    txacoli is offline Novice
    Windows Vista Access 2007
    Join Date
    Nov 2010
    Posts
    19
    I've done a lot since you helped me last week Rixxe, but this has me stumped. I know it's simple, but I can't get through it. I've looked and looked on Google and while there are loads of suggestions, there's nothing I can find there that I can get to work.

    Is there any chance, using the code in my original post, that you - or anyone - could suggest where I could put my DSUM or SUM please? (Polite answers only please!)

  4. #4
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    At least you have been looking (Thats what learning new stuff is all about!)
    This site might help you:
    http://www.techonthenet.com/sql/sum.php

    But what you will need to do is put something like this into your query:
    I havent actually tried this, but it makes sence. (Don't often use SUM function)
    Code:
     
    
    SELECT SUM(Referrals 2010) as "Total referrals" , [Referrals 2010].Assess, Count(*) AS [Number] , [Referrals 2010].Time FROM [Referrals 2010] GROUP BY [Referrals 2010].Assess, [Referrals 2010].Time HAVING ((([Referrals 2010].Assess)="No") AND (([Referrals 2010].Time) Between "07.00-07.59" And "19.00-19.59"));
    I'm not 100% sure about what field you wish to count, so you can change that accordingly.

    Good luck, and if you get stuck im sure someone will be able to help you out.

    Rixxe.

  5. #5
    txacoli is offline Novice
    Windows Vista Access 2007
    Join Date
    Nov 2010
    Posts
    19
    Hi Rixxe

    Thanks for your continued help. I spent about 3 (frustrating!) hours today trying to use the code you'd given me, but to no avail. It adds up the amount of referrals in each time block - which I can already do - but doesn't give me a total number of referrals at the bottom of the 'Number' column, which is what I want to do. I've attached a pic of how I'd like it to look, which is something I can do easily in Access 2007, but not in 2003, which is the system we have at work. (I don't need the word TOTAL in there, it's just that 2007 automatically puts it in)



    If you can help me get that total at the bottom of the 'Number' column using code in 2003, I will be so grateful.

    Thanks in anticipation

    Mark

  6. #6
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    Hmm, can't say i've ever wanted to do that in access.

    You can just use this:

    =Sum([Column name])

    In the design view i believe, which gives you a total of the whole column..
    For this case i think its best either to run two queries, the one with count, then run SUM (Numbers) as another one.

    Although using the UI isn't great, it might be the best thing to get that totals column. (Even in access 2003!)

    You can get that total to be in a different location, say in another column... if thats any use to you.

    Otherwise, hopefully someone else might have the answer.

    Good luck, sorry i can't give you a definite answer.

    Rixxe.

  7. #7
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    The =Sum([Total]) ((Total) here is my column name in the query I want to total))does not work for me, I get an error stating "Subqueries cannot be used in the expression (Sum([Total]))). I think it is because I am already using the expression Total to "Count" maybe? But I am wanting the same thing, to be able to have a "Grand Total" in the same format just by using a query.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query - using Max Totals with Criteria
    By mslieder in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:02 AM
  2. Select query for running totals
    By asawadude in forum Queries
    Replies: 2
    Last Post: 10-07-2010, 03:41 PM
  3. Query Column Totals
    By lmp101010 in forum Queries
    Replies: 1
    Last Post: 08-06-2010, 01:03 PM
  4. Calculating Sub Totals in a Query
    By cassidym in forum Queries
    Replies: 2
    Last Post: 06-09-2010, 01:26 PM
  5. query - totals
    By mslieder in forum Access
    Replies: 0
    Last Post: 02-22-2006, 06:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums