Results 1 to 3 of 3
  1. #1
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410

    Complex Query to obtain result from prior date based on another date?

    Hello,
    Trying to display where the dba_local_bu_rate_effectivedate is one prior to the dba_local_member_status_effectivedate per MemberId



    There are multiple dba_local_bu_rate_effectivedate
    Code:
    MemberId    dba_local_member_status_effectivedate    dba_local_bu_rate_effectivedate    monthly_factor    factor
    002361234    12/1/1997    6/1/1992    36.79    8.49
    002361234    12/1/1997    1/1/1994    41.12    9.49
    002361234    12/1/1997    6/1/1995    42.81    9.88
    002361234    12/1/1997    3/1/1997    43.81    10.11
    002361234    12/1/1997    8/1/1998    44.33    10.23
    002361234    12/1/1997    8/1/2001    47.02    10.85
    002361234    12/1/1997    6/1/2002    47.52    10.97
    002361234    12/1/1997    1/1/2005    48.52    11.2
    002361234    12/1/1997    1/1/2006    49.02    11.32
    002361234    12/1/1997    12/1/2006    50.02    11.55
    002361234    12/1/1997    1/1/2009    51.02    11.79

    What I have so far but not working as hoped
    Code:
    SELECT        MemberId, JobclassId, BargainingUnitId, EffectiveDateMbrPosition, dba_local_bu_jobclass_effectivedate, type, dba_local_member_status_effectivedate,                          dba_local_member_status_member_type, bu_jobclass_seq, dba_local_bu_rate_member_type, MAX(dba_local_bu_rate_effectivedate) AS LastRateEffectiveDate, 
                             MAX(bu_rate_seq) AS LastRateSeq, MAX(monthly_factor) AS LastMonthlyFactor, MAX(factor) AS LastFactor, ssn
    FROM            dbo.AdvancedDues
    GROUP BY MemberId, JobclassId, BargainingUnitId, EffectiveDateMbrPosition, dba_local_bu_jobclass_effectivedate, type, dba_local_member_status_effectivedate, 
                             dba_local_member_status_member_type, bu_jobclass_seq, dba_local_bu_rate_member_type
    HAVING        (MAX(dba_local_bu_rate_effectivedate) < dba_local_member_status_effectivedate)

  2. #2
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410
    Unless there's a better way, I think I have it

    Code:
    SELECT        MemberId, JobclassId, BargainingUnitId, EffectiveDateMbrPosition, dba_local_bu_jobclass_effectivedate, type, dba_local_member_status_effectivedate,                          dba_local_member_status_member_type, bu_jobclass_seq, dba_local_bu_rate_member_type, MAX(dba_local_bu_rate_effectivedate) AS LastRateEffectiveDate, 
                             MAX(bu_rate_seq) AS LastRateSeq, MAX(monthly_factor) AS LastMonthlyFactor, MAX(factor) AS LastFactor, ssn
    FROM            dbo.AdvancedDues
    WHERE        (dba_local_bu_rate_effectivedate < dba_local_member_status_effectivedate)
    GROUP BY MemberId, JobclassId, BargainingUnitId, EffectiveDateMbrPosition, dba_local_bu_jobclass_effectivedate, type, dba_local_member_status_effectivedate, 
                             dba_local_member_status_member_type, bu_jobclass_seq, dba_local_bu_rate_member_type,

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848

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

Similar Threads

  1. Replies: 6
    Last Post: 03-02-2016, 12:58 PM
  2. Replies: 2
    Last Post: 04-13-2015, 10:49 AM
  3. Replies: 20
    Last Post: 01-13-2015, 02:23 PM
  4. Replies: 1
    Last Post: 01-22-2014, 03:45 PM
  5. Replies: 13
    Last Post: 09-27-2010, 03:10 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