尝试运行一个查询,该查询将向我们显示出站线索与入站线索的百分比

时间:2019-03-14 01:46:04

标签: mysql sql inner-join

到目前为止,我们的代码在下面,但它给我们一个错误

Select LeadSource, (count(‘Inbound’) from Lead_T * 100 / select count (LeadSource) from Leads_T)) as percent 
Where LeadID in( select stage
       From opportunities_T  
       Where Opportunities_T.stage = ‘7-Closed/Won’)

表1:

create table Opportunities_T
(Executive varchar(50) not null,
 AccountName varchar(150) not null,
 Stage varchar(50) not null,
 OpAmount int not null,
 CloseDate date not null,
 AccountStatus varchar(15) not null,
 LeadID int not null,
 constraint Opportunities_PK primary key (LeadID, AccountName),
 constraint Opportunities_FK1 foreign key (LeadID) references Leads_T(LeadID),
 constraint Opportunities_FK2 foreign key (AccountName) references Account_T(AccountName));

表2:

create table Leads_T
(Contact varchar(25),
Company varchar(100),
Title varchar(150),
LeadSource varchar(30),
BDR varchar(50),
LeadID int,
constraint Leads_PK primary key (LeadID));

0 个答案:

没有答案