我想要输出如下 [英] I want the output as follows

查看:77
本文介绍了我想要输出如下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2张桌子

表1:

 EmployeeId EmployeeName 
12 vivek
16 siva
26 prasanth
34 mahesh



表2:

员工薪酬
13 45000
14 12000
16 50000
26 58222



我希望输出如下



员工身份
12 N
16 Y
26 Y
34 N





如果table1中的employeeid存在于table2列表的employeeid中,那么它应该将输出设为''Y''别人''N''



代码块添加 - OriginalGriff [/ edit]

解决方案

解决了你的问题..

 选择 t1.employeeid, case   isnull时(t2.salary, 0 )= 0 然后 '  N'   else  '  Y'  end   as  ' 状态 
来自 table1 t1 left 外部 join table2 t2 on t2.employeeid = t1。雇员


I have 2 tables
Table1:

EmployeeId    EmployeeName
    12          vivek
    16          siva
    26          prasanth
    34          mahesh


Table2:

Employeeid     Salary
 13             45000
 14             12000
 16             50000
 26             58222


I want the output as follows

Employeeid       Status
  12              N
  16              Y
  26              Y
  34              N



If the employeeid in the table1 is present in the employeeid of table2 list then it should give the output as ''Y'' else ''N''

[edit]Code block added - OriginalGriff[/edit]

解决方案

solved your problem..

select t1.employeeid,case when isnull(t2.salary,0) =0 then 'N' else 'Y' end as 'Status'
from table1 t1 left outer join table2 t2 on t2.employeeid=t1.employeeid


这篇关于我想要输出如下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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