Results 1 to 3 of 3

Thread: Working with compressed data

  1. #1
    Join Date
    Apr 2007
    Posts
    2

    Working with compressed data

    Hello,
    I have a table of compressed data and am looking for an efficient way to expand the data for reporting purposes.
    The table is used to store the number of hours a given contractor works and is stored in the following fashion:

    cnt Hours
    5 8
    2 0
    5 8
    2 0

    The first row represents the number of sequential days where an employee worked the same # of hours. Once the # of hours changes, a new record is created. In this simple example, the first row shows an employee working Monday-Friday (5) for a total of 8 hours each day. The second row represents the weekend (2 days) where the employee worked 0 hours.

    What I need to do is explode this out to show 1 record per day. Ideally I'd like to write a function to do this as I would be linking to another table which has the start and end date for the contractor and would allow me to apply individual dates to each record based on the contractor start date through to the end date.

    Thanks for any help you can provide!

  2. #2
    Join Date
    Dec 2004
    Posts
    502
    Is there another column in your table (like a row number or a record number) that lets you know the sequence of these "compressed" records? Otherwise, there's no way to know that cnt = 2 follows cnt = 5.

  3. #3
    Join Date
    Apr 2007
    Posts
    2
    correct - The table will have sequence number from which to ensure where to start.

Posting Permissions

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