473,382 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Combine multiple records into a date time line.

5
I have a data file that contains multiple records for each employee. I'm trying to build a view of the table that would show me a combined date range for per location. The example below are the fields from the file that i'm trying to combine.

Table Exp:
Employee # Begin Date End Date Location
1 1/1/2005 10/1/2005 BRD
1 10/2/2005 5/31/2007 BRD
1 6/1/2007 3/31/2009 RMC
1 4/1/2009 9/30/2010 RMC
1 10/1/2010 BRD

I'm trying to get a view that would show me:
Employee # Begin Date End Date Location
1 1/1/2005 5/31/2007 BRD
1 6/1/2007 9/30/2010 RMC
1 10/1/2010 BRD
Feb 1 '12 #1

✓ answered by Rabbit

Make an attempt with the information in the doumentation. Post any errors you get and we can help you through them.

7 3094
Rabbit
12,516 Expert Mod 8TB
You'll have to use a cursor for that. Here's a link to the documentation discussing cursors. http://msdn.microsoft.com/en-us/library/ms180169.aspx
Feb 1 '12 #2
ck9663
2,878 Expert 2GB
What's the basis for grouping? Are you just getting the value from the second row? Are there only two rows? 'Coz your last record does not seem to have a pair.


~~ CK
Feb 1 '12 #3
mattd
5
Sorry the data didn't upload visually as I was hoping for.
What I'm trying to do is capture the first and last date each time the employee changes location.
So i'm hoping to get 3 lines out of the data.
1) 1/1/2005 - 5/31/2007 date range for location = BRD.
2) 6/1/2007 - 9/30/2010 date range for location = RMC.
3) 10/1/2010 - null (current) date range for location = BRD.
Feb 2 '12 #4
mattd
5
Thanks, I'll check it out.
Feb 2 '12 #5
mattd
5
Rabbit thanks for the info but I have no idea how to set this up. I'm pretty new at SQL, would you be able to show me how to set something like this up with Cursor?
Feb 2 '12 #6
Rabbit
12,516 Expert Mod 8TB
Make an attempt with the information in the doumentation. Post any errors you get and we can help you through them.
Feb 2 '12 #7
mattd
5
Rabbit, I found a SQL guys at the office. He helped me build the Cursor query which worked. Thanks for pointing me in the right direction.
Feb 7 '12 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: glenn | last post by:
I'm really scratching my head over this one. I'm working with CSV data exported from Excel, which explains why it's a mess to begin with. Within a table (or via any other means someone might be...
5
by: Javier | last post by:
I have a field type Date/Time that automatically defaults to Now(). I'm having a problem writing a query that will retrieve all the records for a specific date the user to enters when prompted. I...
5
by: jhutchings | last post by:
Hello everyone, I have a database where I collect shipment data from various tables. However, I have a problem. Whenever I want to see shipping data for orders that were set to ship on or before...
4
by: musicloverlch | last post by:
I have a table with multiple records in it. I am being forced to combine multiple records into one record in order to be uploaded to a website, and I only get one record per client. How can I...
1
by: rdraider | last post by:
Hi all, We have an app that uses SQL 2000. I am trying to track when a code field (selcode) is changed on an order which then causes a status field (status) to change. I tried a trigger but...
13
by: franzey | last post by:
This is how the data is organized: vID Answer 12 Satisfied 12 Marketing 12 Yes 15 Dissatisfied 15 Technology 15 No
2
by: HansyW | last post by:
Please help I m reading data and need to output to a file. For each record, I have a header and several details records. I need the header to be on one line, all the details on another line , and...
4
by: ME2007 | last post by:
Can anyone help me to write a t-sql script to import a txt file to sql server 2000? I received a text report from a vendor that i need to extract the data for calculations. Each patient account has...
4
werks
by: werks | last post by:
Hello experts could someone tell me how can i combine multiple records into one value. Sample in MS Access: (Lastname & "" & "," & " " & Firstname) AS Name How can i do this in MySQL?..tnx in...
1
by: bluereign | last post by:
Thank you for your assistance. I am a novice looking to JOIN and append or combine records from 2 current Tables into 2 new Tables named below. I have been able to JOIN Tables with the script...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.