select a.unitid,a.Projectid,a.ProjectName,a.SalePlan,
a.estimate,a.StartTime,a.EndTime,a.sales,a.InputTime,
a.ForecastMoney,b.Name
from Project a,Archives b
where a.sales=b.userid
and (a.sales='Su' )
Union
select a.unitid,a.Projectid,a.ProjectName,a.SalePlan,
a.estimate,a.StartTime,a.EndTime,a.sales,a.InputTime,
a.ForecastMoney,b.Name
from Project a,Archives b
where a.sales=b.userid
and a.projectid in (select projectid from ProAccredit where userid='Su')
a.estimate,a.StartTime,a.EndTime,a.sales,a.InputTime,
a.ForecastMoney,b.Name
from Project a,Archives b
where a.sales=b.userid
and (a.sales='Su' )
Union
select a.unitid,a.Projectid,a.ProjectName,a.SalePlan,
a.estimate,a.StartTime,a.EndTime,a.sales,a.InputTime,
a.ForecastMoney,b.Name
from Project a,Archives b
where a.sales=b.userid
and a.projectid in (select projectid from ProAccredit where userid='Su')
a.estimate,a.StartTime,a.EndTime,a.sales,a.InputTime,
a.ForecastMoney,b.Name
from Project a,Archives b
where a.sales=b.userid
and (a.sales='Su' or exists (select 1 from ProAccredit where userid='Su' and projectid=a.projectid))
或者(不知道你的projectid字段是那个表的):
and (a.sales='Su' or exists (select 1 from ProAccredit where userid='Su' and projectid=b.projectid))
将数据类型 varchar 转换为 numeric 时出错。
这个错误是最后一个条件:
[...and a.projectid in (select projectid from ProAccredit where userid='Su')]
当括号中查询值为空时,就会出这个错,也就是说,proaccredit中没数据时要处理一下
请继续关注,谢了!
a.estimate,a.StartTime,a.EndTime,a.sales,a.InputTime,
a.ForecastMoney,b.Name
from Project a,Archives b
where a.sales=b.userid
and (cast(a.sales as varchar(100))='Su' or cast(projectid as varchar(100)) in (select projectid from ProAccredit where userid='Su'))
已经好几天了,不会要让我写两句SQL来实现吧!