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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Getting second Call Date

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_date
into #temp1
from #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_id

select * from #temp1
order by 1


The 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 =2
What 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??
Go to Top of Page

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 table

Thanks,
Petronas
Go to Top of Page

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]

Go to Top of Page
   

- Advertisement -