Open ExpandedVenture opened 3 years ago
/*
-- to be sure there are not repeated names reached by different accounts
select COUNT(r.id), COUNT(distinct r.id), COUNT(distinct x.name)
from pipeline p with (nolock)
join [user] u with (nolock) on u.id=p.id_user
join client c with (nolock) on c.id=u.id_client
join [message] m with (nolock) on (p.id=m.id_pipeline and m.trigger_type=2 and m.delete_time is null and m.status=1)
join lnchat h with (nolock) on (m.id=h.id_message and h.direction=0 and h.inmessage_end_time is not null)
join result r with (nolock) on r.id=h.id_result
join [profile] x with (nolock) on x.id=r.id_profile
join lnuser y with (nolock) on y.id=h.id_lnuser
where c.name = 'Expanded Venture 2'
--and (p.name not like 'Selling CS Prospecting')
and p.delete_time is null
and y.delete_time is null
*/
/*
-- geting the pipelines
insert into [message]
(id, create_time, id_user, trigger_type, trigger_delay_days, trigger_param, [status], id_pipeline, [name], body)
select NEWID(), GETDATE(), p.id_user, 3, 15, '', 1, p.id, 'testing followup 3',
'Hello !fname,
We {have been|are} {connected|contacts} {here|} on LinkedIn {for a while|for a long time now|since weeks ago}, but {I guess|} we never {had a call|had a conversation|had a chat|met} {before|so far}.
{If you don''t mind can you answer|Can I ask|Can you answer} one quick question?
{What is|What''s} {it that you|the one thing that you} {most|} struggle with when {it comes|trying} to grabbing new clients for your {business|company}?
{The reason|Why} {I am|I''m} asking is because {We are|We''re} {working on|putting the last touches to|going to release a}
new software for {getting appointments|get meetings} with leads that {you will|you''ll} love, and you may {try|test} it {for free|at no cost} for {2|two} weeks.
So, your answer will be rewarded {;)|:D|:)|!}
{I await|Looking forward for} your reply..'
from pipeline p with (nolock)
join [user] u with (nolock) on u.id=p.id_user
join client c with (nolock) on c.id=u.id_client
where c.name = 'Expanded Venture 2'
and (p.name not like 'Selling CS Prospecting')
and p.delete_time is null;
-- geting the searches
insert into search_message
select newid(), getdate(), p.id_user, s.id, o.id
from pipeline p with (nolock)
join [user] u with (nolock) on u.id=p.id_user
join client c with (nolock) on c.id=u.id_client
join [message] m with (nolock) on (p.id=m.id_pipeline and m.delete_time is null and m.trigger_type=2 and m.status=1)
join search_message x with (nolock) on m.id=x.id_message
join search s with (nolock) on s.id=x.id_search
join [message] o with (nolock) on ( p.id=o.id_pipeline and o.delete_time is null and o.trigger_type=3 and o.status=1 )
where c.name = 'Expanded Venture 2'
and (p.name not like 'Selling CS Prospecting')
and p.delete_time is null
order by p.id, s.id
*/
--select * from template
create table strategy (
[id] uniqueidentifier not null,
[name] varchar(500) not null,
id_example_pipeline uniqueidentifier null references pipeline([id]), -- fk to a pipeline who used this strategy, to show its conversion
id_example_search uniqueidentifier null references search([id]), -- fk to a search who used this strategy, to show its filters
script_example text not null,
template_number int not null,
...