CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    2

    Displaying first instance of data

    Hi,

    I'm having some trouble with a report I'm trying to generate. It is essentially activity status of a bunch of users that are on the system. The raw data displays the date and time, user, what state they are currently in and what state they changed to and duration.

    My problem is I only need the first and last instance for each day. Since a user can go through many states in a day, the data is quite long and to have to filter through the data by hand is quite cumbersome.

    Is there a way display the data but just show only the first instance for that date and last instance for the date assuming i have a parameter that is a date range?

    Thanks

  2. #2
    Join Date
    May 2001
    Posts
    91

    Re: Displaying first instance of data

    Select top 1 [fieldnames ...] from [Tablename] ..... Order by Primary key desc

    delievers the first and

    Select top 1 [fieldnames ...] from [Tablename] ..... Order by [Primary key] asc

    delievers the last entry.
    have a nice day

    Patzer
    _____________________________
    Philo will never be forgotten

  3. #3
    Join Date
    Oct 2005
    Posts
    2

    Re: Displaying first instance of data

    I'm not quite sure where to put this:

    Here is more information on the problem.

    I have 3 group names. First is Name, second is time (Day MM/DD/YY), third is time (H:MM)

    What I would like to do is for each day, calculate the maximum and minimum of the time

    However when I do Minimum (Date) I get the minimum of ALL the days, and not just for that particular date.

    For example, my data has 8 users, and has data for about 30 days on each user. Each day a user can have multiple activities, ranging from 8am to 6pm. All I want to calculate or see, is the first time and the last time for that particular day

    Any ideas? I'm trying to create a formula using the minimum function but to no avail.

  4. #4
    Join Date
    Jul 2004
    Location
    Chennai, India
    Posts
    1,064

    Re: Displaying first instance of data

    What is the database you are using?
    Post table structures, sample data and the result you want
    Madhivanan

    Failing to plan is Planning to fail

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured