|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Comapring a record in table with other records in same table
Hi,
We want to compare one record in a table with other remaing records of the table that meet a criteria of a business logic. eg.I have startcall_time,end_calltime as fields with other 50 fields. As a business logic we need to subtract start_calltime of new record from end_calltime of previous record and do some calculations.These calculations have to be done for all the calls where endcalltime(of a record)-startcall(timeof a different record )meet a criteria. A procedure in MS SQl is what we need to write. Please help . Regards AJ |
|
#2
|
|||
|
|||
|
DDL would help, but you could try this as a vague starting point:
select ... from yourtable t1 join yourtable t2 on (t1.field-t2.field=criteria and t1.id<>t2.id) You are joining the table with itself, on your criteria. tim |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Comapring a record in table with other records in same table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|