Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jul 2006
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Grouping of Data (2003)

    Hi Folks. in the query grid, there are ways of selecting First and Last of groups of records, summing, counting and whatever. What I'm trying to do is to find the first value against an Id number and the second, and compare them. Is there an easy way to do this?

    Much appreciate your help.

    Ina

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Grouping of Data (2003)

    First and second in terms of what? Remember that a table doesn't have an intrinsic sort order, so First and Last return unpredictable results unless you specify on which field(s) you want to sort the data.

  3. #3
    Star Lounger
    Join Date
    Jul 2006
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Grouping of Data (2003)

    Hi Hans, Three fields - Id, Period and Value. Id has multiple periods against which are varied values e.g.

    Id 1
    Periods, 2, 3, 4
    Value, 5, 6 7

    I need to check whether Id 1 Periods 2 and 3 match.

    Does this help?

    Cheers.

    Ina

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Grouping of Data (2003)

    I think you need a series of queries for this. The attached database shows a possible approach, there may well be other ways to accomplish it.

    qryFirst returns the first Period for each ID.
    qryTop2 returns the first two Periods for each ID.
    qryFirstValue returns the Value of the first Period for each ID.
    qrySecondValue returns the Value of the second Period for each ID (if available).
    qryCompareFirstAndSecond combines the latter two to return the values of the first and second Period for each ID.
    Attached Files Attached Files

  5. #5
    Star Lounger
    Join Date
    Jul 2006
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Grouping of Data (2003)

    Hi Hans, yes the Top Two thing is the key - didn't think of that!

    Thanks very much for the help, as always.

    Kind regards.

    Ina

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •