Results 1 to 4 of 4
  1. #1
    Kiz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    2

    Needing to build a query to rank something by date order - please help!

    Hi all,

    I am currently building a database to work out commission payable. I have hit a snag when it comes to working out some "commission kickers" (e.g. on the third settled deal commission goes from A% to B% etc).



    I basically need to rank the deals by the date they were settled for each referring company... Below is a mock table of what i need as an outcome of a query... but i am unsure how to build the query itself! and i'm not exactly savvy with SQL views and coding. THANK YOU!

    Referring Company DealName DateSettled Rank
    Introducer A DealCat 09 Dec 4
    Introducer A DealDog 21 Feb 2
    Introducer A DealFish 10 Aug 3
    Introducer A DealHorse 06 Jan 1
    Introducer B DealCow 07 Oct 2
    Introducer B DealAnt 16 Dec 3
    Introducer B DealRabbit 11 Jul 1
    Introducer C DealShark 06 Dec 1
    Introducer D DealBird 08 Jan 1
    Introducer D DealElephant 25 Dec 2

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    So you need to count how many records for each company and alter the commission for the records after some threshold?

    This can get tricky. Criteria that is based on other records of same table seldom easy. For a start review http://allenbrowne.com/ranking.html

    Also, DCount() might be an option but domain aggregate functions can be slow.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Kiz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    2
    Thanks for that! That has now enabled me to rank each deal based on settlement date (which is awesome) - not sure if I am pushing my luck asking this, but do you know how to now group the rankings by the introducing company?

    Here is the current SQL view of the query if that helps?

    SELECT qryDates.ClientID,qryDates.TotalValue,
    (SELECT Count([ClientID]) AS HowMany
    FROM qryDates AS Dupe
    WHERE Dupe.TotalValue < qryDates.TotalValue)+1 AS BeatenBy
    FROM qryDates;

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Your sample data does not show TotalValue. Is introducing company synonymous with referring company?

    You want ranking within each group (company)? Maybe:

    WHERE Dupe.TotalValue < qryDates.TotalValue AND Dupe.Company = qryDates.Company
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. How to order query records by date
    By behnam in forum Queries
    Replies: 1
    Last Post: 08-29-2014, 08:19 AM
  2. Replies: 10
    Last Post: 07-04-2014, 12:29 AM
  3. how to rank using a query in acess 2007
    By BRAYAN RYAN VAN KYAN in forum Queries
    Replies: 1
    Last Post: 08-13-2013, 02:11 AM
  4. Needing Sub Query Help
    By djclntn in forum Queries
    Replies: 10
    Last Post: 11-15-2012, 01:49 PM
  5. still needing help on update query button
    By cdell7up in forum Access
    Replies: 3
    Last Post: 08-04-2012, 11:21 AM

Tags for this Thread

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