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 |
|
Petronas
Posting Yak Master
134 Posts |
Posted - 2009-04-24 : 16:00:20
|
| Hi All,Hi All,I have the following query which gets the records based on the cancel_date:select order_id,order_date,call_date ,cancel_dateinto #temp1from #temp_calls t with (nolock)where Service_ID = 1 --Cancelled and (cancel_date >(select min(call_date) from #temp_orders with (nolock) where t.order_id=order_id))group by order_id,order_date,cancel_date,marketing_partner,customer_service_call_reason_idselect * from #temp1order by 1The way it works is one order_id could have multiple service_id's.one order_id could have multiple call_dates. So every time a customer called and was persuaded to continue with the service that would be a Save (Service_Id=2).So one order_id could have multiple service_id's =2What I want is to get count of customers who called in the second time and cancelled.I don't know how to go about getting only the second call which had a service_id=2 before.Thanks,Petronas |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-04-24 : 17:05:20
|
| I dont understand the structure of your tables. You have cancel_Date in calls table ? call_date in orders?? |
 |
|
|
Petronas
Posting Yak Master
134 Posts |
Posted - 2009-04-27 : 10:19:46
|
| Hi Sakets 2000,I have Call_Date in Call table and the Cancel_Date in the Orders tableThanks,Petronas |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-04-27 : 21:19:03
|
Petronas,It will be easier for others to understand what you want here if you can post the table structure with sample data and the required result / output KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|