简体   繁体   中英

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

I am new to SQL. Here is my question: I get two temporary tables:

表格1 表 2

I want to add a new column to the first table to see if employee's score meets his position average.

Can someone help me with the code?

Thank you so much

You can join the information and compare the Performance with 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM