簡體   English   中英

SQL 根據另一個表中的值添加一列二進制值

[英]SQL add a column of binary values based on values from another table

我是 SQL 新手。 這是我的問題:我得到兩個臨時表:

表格1 表 2

我想在第一個表中添加一個新列,以查看員工的分數是否符合其職位平均值。

有人可以幫我寫代碼嗎?

非常感謝

您可以加入信息並將 Performance 與 Avg 進行比較

select Employee, JobPosition, [Performance Score], [Ave. Performance]
, case 
    when Emp.[Performance Score] >= [Ave. Performance] then 'Meet' 
    else 'Does not meet'
  end AS PerfResult
from Emp
    inner join Perf on Perf.JobPosition = Emp.JobPosition

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM