SQL-lead_id、account_id 以及lead created_date 和账户created_date 之间的天数是多少 [英] SQL- What is the lead_id , account_id and the number of days between lead created_date and the account created_date

查看:30
本文介绍了SQL-lead_id、account_id 以及lead created_date 和账户created_date 之间的天数是多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于与帐户关联的每个潜在客户,lead_id、account_id 以及潜在客户 created_date 和帐户 created_date 之间的天数是多少?

For each lead associated with an account, what is the lead_id, account_id, and the number of days between the lead created_date and the account created_date?

lead_id    created_date     industry
INT DATE    VARCHAR (25)

例如2345566 2019-01-25 销售

e.g. 2345566 2019-01-25 sales

account_id    created_date  lead_id
INTEGER DATE (YYYY-MM-DD)   INTEGER

例如 34345564 例如2019-03-14 123152

e.g 34345564 e.g. 2019-03-14 123152

我已经试过了

Select
Distinct Lead_id,
Distinct Account_id
Datediff(days,l.created_date,a.created_date)
From
Lead l
Join 
Account a
On a.lead_id= l.lead_id

推荐答案

为此,您不需要 distinct.假设您使用的是 SQL Server:

You don't need distinct for this. Assuming you are using SQL Server:

Select Lead_id, Account_id
       Datediff(days, l.created_date, a.created_date)
From Lead l Join 
     Account a
     On a.lead_id = l.lead_id;

这篇关于SQL-lead_id、account_id 以及lead created_date 和账户created_date 之间的天数是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆