Students
我有以下查询,它从 2 个表(和Subjects
)中收集一些信息
SELECT
'StudentName' As Student,
'Class' As Class,
'Subject' As Subject
DATEDIFF( HOUR, hoursSpent.ClassStartTime, hoursSpent.ClassEndTime ) As HoursSpent
FROM (
SELECT stu.StudentName from Students s
INNER JOIN Subjects sub
WHERE stu.StudentId = sub.StudentId
) hoursSpent
Students
我有另一个与布局中的表完全相同的表,称为OldStudents
.
我的问题是我想将两者的数据结合起来Students
并OldStudents
显示为一个,但不知道如何做到这一点。
我试过了,但这不起作用:
SELECT
'StudentName' As Student,
'Class' As Class,
'Subject' As Subject
DATEDIFF( HOUR, hoursSpent.ClassStartTime, hoursSpent.ClassEndTime ) As HoursSpent
SELECT(
FROM (
SELECT stu.StudentName from Students s
INNER JOIN Subjects sub
WHERE stu.StudentId = sub.StudentId
) hoursSpent,
FROM (
SELECT stu.StudentName from Students s
INNER JOIN Subjects sub
WHERE stu.StudentId = sub.StudentId
) hoursSpent )