Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cekirge
Starting Member
4 Posts |
Posted - 2006-02-02 : 09:56:42
|
| Hello,I have two tables that I would like to combine but with some rules.Table 1 has two columns with Actual Time and Actual PeopleTable 2 has two columns also with Planned Time and Planned PeopleI would like to combine these two tables if the actual time is not more than 30 minutes from a planned timeIf I use one of the planned times, i would not want to show it again, even if there is another actual time that is not more than 30 minutes of it.For ex.Planned Time has 20:00,23:00Planned People has 2,5Actual Time has 19:00,19:30,19:45,21:15Actual People has 5,2,5,3Output should be likePlanned_Time,Actual_Time,Planned_People,Actual_People,19:00,,520:00,19:30,2,2,19:45,,5,21:15,,323:00,,5,I can do this in asp but if this can be done in sql it would be better.Any ideas appreciated.Thanks. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-02 : 18:29:47
|
| What is the PK for these 2 tables ? Post the table structure----------------------------------'KH' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-03 : 01:10:38
|
| >>I can do this in asp but if this can be done in sql it would be better.Then why do you want to do in SQL?MadhivananFailing to plan is Planning to fail |
 |
|
|
cekirge
Starting Member
4 Posts |
Posted - 2006-02-03 : 15:49:31
|
quote: Originally posted by madhivanan >>I can do this in asp but if this can be done in sql it would be better.Then why do you want to do in SQL?MadhivananFailing to plan is Planning to fail
I want to use the summarize the information and use it on the other pages.quote: Originally posted by khtanWhat is the PK for these 2 tables ? Post the table structure
Is this what you were looking for, both tables have the same structure0 Planned_Time datetime 8 -11 Planned_People tinyint 1 -1Thanks |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-03 : 17:38:52
|
| You mean you table has only 2 columns ? Then how do you determine which planned data is related to which actual data ? Can you also explain more on how to obtain the result ?Aslo refer to this http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx----------------------------------'KH' |
 |
|
|
|
|
|
|
|