Results 1 to 13 of 13
  1. #1
    Mikekim is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    5

    Query Sum Help

    I have a list of players (TOT_KEY), there top 10 finishes (FINISHED), sum of winnings (SUMOFWINNINGS).
    My problem is FINISHED contains numbers and letters, example 2-T, 3-T, 4-T through 10-T ETC.
    I need to sum the SUMOFWINNINGS by each player (TOT_KEY).
    I have exported the data to Excel and I am going to try and attach the Excel file.
    Any help would be greatly appreciated. Once I get this I think I can figure out how to combine the queries to get the data I am after.


    Thanks
    Mike
    Attached Files Attached Files

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I think it should be possible using InStr() and Left() functions
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Something like below called from within SQL getposition numfinish: Getposition(finished)

    Code:
    function getposition (posstring as text) as integer
    dim mypos() as string
    if isnumber(posstring) = true then
    getposition = posstring
    exit function
    else
    mypos = split (posstring,"-")
    getposition = mypos(0)
    end if
    end function

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    if FINISHED = "2-T" , then in the query separate using: left(FINISHED,instr(FINISHED,"-")-1)

    you should get : 2

  5. #5
    Mikekim is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    5
    Well I tried the examples but I am getting errors. Here is the SQL in Query6
    SELECT SJGOLF.TOT_KEY, SJGOLF.FINISHED, Sum(SJGOLF.WINNINGS) AS SumOfWINNINGS
    FROM SJGOLF
    GROUP BY SJGOLF.TOT_KEY, SJGOLF.FINISHED;

    Is it possible to attach the Access file? I'm new to this.
    Mike

  6. #6
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Feel free to attach it but zip it first. We'll happily take a look.

  7. #7
    Mikekim is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    5
    Here is the attached file.
    I sure I'm taking the wrong approach. This came from Dbase III. I know what I'm doing there but getting it in Access is a real challenge.
    Thank you for all your help.
    Mike
    Attached Files Attached Files

  8. #8
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    could we have a copy of the linked table?

  9. #9
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Try leaving out sjgolf.finished from all parts as well.

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I think the SQL for query should be:
    Code:
    SELECT Sum(Left([FINISHED],InStr([FINISHED],"-")-1)) AS SumOfFinishedNum, SJGOLF.TOT_KEY
    FROM SJGOLF
    GROUP BY SJGOLF.TOT_KEY;
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    Mikekim is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    5
    Here is the linked table
    Told you I was new to this.....
    Mike
    Attached Files Attached Files

  12. #12
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Click image for larger version. 

Name:	golf.png 
Views:	10 
Size:	19.3 KB 
ID:	28986If you only need a list of players and the sum of their winnings then,

    Code:
    SELECT SJGOLF.TOT_KEY, Sum(SJGOLF.WINNINGS) AS SumOfWINNINGS
    FROM SJGOLF
    GROUP BY SJGOLF.TOT_KEY;

  13. #13
    Mikekim is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    5
    Quote Originally Posted by andy49 View Post
    Click image for larger version. 

Name:	golf.png 
Views:	10 
Size:	19.3 KB 
ID:	28986If you only need a list of players and the sum of their winnings then,

    Code:
    SELECT SJGOLF.TOT_KEY, Sum(SJGOLF.WINNINGS) AS SumOfWINNINGS
    FROM SJGOLF
    GROUP BY SJGOLF.TOT_KEY;
    This gives me the total winnings of all players my dilemma is I need the totals of only the players that finished in the top 10 places.
    1, 2, 2-T, 3, 3-T, 4, 4-T, 5, 5-T, 6, 6-T, 7, 7-T, 8, 8-T, 9, 9-T, 10, 10-T.
    The players that tied is what I don't seem to be able to pull accurately, because of the -T in the finished place.
    Mike

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

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