我该如何在SQL中获得以下输出?

时间:2013-08-28 13:39:20

标签: sql oracle mysqli

我有两个表Employee和Grade,想要输出像第三个表(即输出表)?  如果可能的话怎么样?

I Have Employee Table with following Data

Similarly i have Garde Table with following data

Is it possible to get the following output ? if yes then how ?

2 个答案:

答案 0 :(得分:4)

你可以试试这个

select e.name , g.grade 
from employeetable e, gradetable g 
where  e.salary >= g.min 
and  e.salary <= g.max 

答案 1 :(得分:2)

试试这个

SELECT 
  E.Name
  ,(SELECT G.Grade FROM Grade G WHERE E.Salary BETWEEN G.Min AND G.Max) 
FROM  Employee E