这条语句出错了。

select PersonId as 职员编码, Personname as 职员名称,性别=(case where sex=1 then '男' else '女' end),
部门=(select deptname from ytdept where deptbh=ytpersonid.deptbh),
Birth as 生日, Jbgz as 工资,Xuli as 学历,
员工类别=(select PCname from YtpersonClass where PCbh=ytperson.Pcbh),Sfzh as 身份证号,Address as 地址,
Tel as 家庭电话,dwtell as 工作电话,Email as Email地址,
业务员=(case where Ywypz=0 then '否' else '是' end ),
在职=(case where online=0 then '否' else '是' end )
from ytperson
Where Personname Like '23%' And sex=1
---------------------------------------------------------------

case 后不是where而是when

另:
select deptname from ytdept where deptbh=ytpersonid.deptbh
select PCname from YtpersonClass where PCbh=ytperson.Pcbh
返回的结果可能有多条记录。

---------------------------------------------------------------

部门=(select deptname from ytdept where deptbh=ytpersonid.deptbh),

这句不对,不能用子查询,不合语法
---------------------------------------------------------------

select PersonId as 职员编码,
Personname as 职员名称,
性别=(case when sex=1 then '男' else '女' end),
部门=(select deptname from ytdept where deptbh=ytperson.deptbh),
Birth as 生日,
Jbgz as 工资,
Xuli as 学历,
员工类别=(select PCname from YtpersonClass where PCbh=ytperson.Pcbh),
Sfzh as 身份证号,
Address as 地址,
Tel as 家庭电话,
dwtell as 工作电话,
Email as Email地址,
业务员=(case when Ywypz=0 then '否' else '是' end ),
在职=(case when online=0 then '否' else '是' end )
from ytperson
Where Personname Like '23%' And sex=1

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus