如何在不使用join的情况下找到数据库中两个表的区别?

时间:2021-04-22 21:30:15

I need to find the difference between highest salary from a table called myproject.faculty and the highest salary from a table called myproject.staff. How can I do that?

我需要找到一个名为myproject.faculty的表中的最高薪水与一个名为myproject.staff的表中的最高薪水之间的差异。我怎样才能做到这一点?

SQL Query:

SELECT *
FROM myproject.faculty

Result:

ID  FIRSTNAME   LASTNAME    CITY    STATE   ZIP     SALARY  DEPT    BIRTH_DATE  PHONE 
102     Jack    Sue     Frostburg   MD  21532   109000  COSC        3016783232 
1   Jo  Andorfer    Aberdeen    MD  21532   80000.89    COSC    01-FEB-81   301-687-5678 

SQL Query:

SELECT *
FROM myproject.staff

Result:

ID  FIRSTNAME   LASTNAME    CITY    STATE   ZIP     SALARY  BIRTH_DATE  PHONE 
1   Xin     Zheng   Aberdeen    MD  21532   80000.89    01-FEB-81   301-687-5678 
2   Gerri   Wojnar  Aberdeen    FL  33423   78000.25    22-JAN-88   301-687-5679 

1 个解决方案

#1


Try following

select (select max(salary) from myproject.faculty) - (select max(salary) from myproject.staff)

#1


Try following

select (select max(salary) from myproject.faculty) - (select max(salary) from myproject.staff)