我在5月6日正在学习数据库考试,而且我在前几年的论文中无法解决问题。我正在尝试做一部分' d' (列表中的4个)。
到目前为止,我有这个,但不知道如何完成它
select count(*) as peopleOlderThanEmployeeNo100
from EMPLOYEE, DEPT
where (dept.name = 'finance') and (employee.dateOfBirth < ?);
问题4
SQL数据库具有以下表格:
[EMPLOYEE]
[EmpNo] Integer (Primary Key)
[Name] Char(30)
[Salary] Decimal(7,2)
[StartDate] Date
[DateOfBirth] Date
[Dept] Char(12) (Foreign key references DEPT( Name ) )
[DEPT]
[Name] Char(12) (Primary Key)
[CostCentre] Char(4)
编写SQL语句以执行以下操作:
答案 0 :(得分:0)
使用像这样的子查询
select count(*) as peopleOlderThanEmployeeNo100
from EMPLOYEE, DEPT
where (dept.name = 'Finance')
and (employee.dateOfBirth < (select dateOfBirth
from EMPLOYEE
where EmpNo = 100));