ordered names to select oldest one created
This commit is contained in:
parent
f2abd16a44
commit
55539ab2c9
2 changed files with 23 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ with
|
|||
u.company_name as core_company_name,
|
||||
c.core_company_name_count,
|
||||
row_number() over (
|
||||
partition by u.id_deal order by u.company_name
|
||||
partition by u.id_deal order by u.created_at_utc
|
||||
) as row_num
|
||||
from int_core__unified_user u
|
||||
left join core_deal_counts c on u.id_deal = c.id_deal
|
||||
|
|
@ -40,7 +40,9 @@ with
|
|||
h.id_deal,
|
||||
h.deal_name as hubspot_deal_name,
|
||||
c.hubspot_deal_name_count,
|
||||
row_number() over (partition by h.id_deal order by h.deal_name) as row_num
|
||||
row_number() over (
|
||||
partition by h.id_deal order by h.created_at_utc
|
||||
) as row_num
|
||||
from int_hubspot__deal h
|
||||
left join hubspot_deal_counts c on h.id_deal = c.id_deal
|
||||
where h.id_deal is not null
|
||||
|
|
@ -64,7 +66,7 @@ with
|
|||
x.contact_name as xero_contact_name,
|
||||
c.xero_contact_name_count,
|
||||
row_number() over (
|
||||
partition by x.id_deal order by x.contact_name
|
||||
partition by x.id_deal order by x.updated_at_utc
|
||||
) as row_num
|
||||
from int_xero__contacts x
|
||||
left join xero_contact_counts c on x.id_deal = c.id_deal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue