我需要使用下面的查询在C#中创建Table Adapter
。我在我的程序中使用MS Access数据库。
我无法直接在Select查询中使用IIF
,Switch
,Case
,而不是加入这两个查询,因为Visual Studio表适配器不支持它。
请参阅我写的这个问题 - Link
我尽力做到最好。但他们都没有帮助我。
实际上这就是我想做的事情 - How to select the same field twice with different conditions
查询 - 1 :
SELECT
t1.Present, t2.Absent
FROM
(SELECT
EmpID, COUNT(*) AS Present
FROM
EmpAttendance
WHERE
AttendStatus = 'Present'
GROUP BY
EmpID) t1
LEFT JOIN
(SELECT
EmpID, COUNT(*) AS Absent
FROM
EmpAttendance
WHERE
AttendStatus = 'Absent'
GROUP BY
EmpID) t2 ON t1.EmpID = t2.EmpID
查询 - 2 :
SELECT
EmpAttendance.EmpID,
EmpAttendance.Empname,
EmpAttendance.EmpSex,
EmpAttendance.EmpDepartment,
EmpProfileTBL.Salary
FROM
((EmpAttendance
INNER JOIN
LocalVariableTable ON EmpAttendance.EmpDepartment = LocalVariableTable.TempDepartment
AND DATEPART('m', EmpAttendance.DateOfAttendance) = LocalVariableTable.TempMonth
AND DATEPART('yyyy', EmpAttendance.DateOfAttendance) = LocalVariableTable.TempYear)
INNER JOIN
EmpProfileTBL ON EmpAttendance.EmpID = EmpProfileTBL.EmpID)
GROUP BY
EmpAttendance.EmpID,
EmpAttendance.Empname,
EmpAttendance.EmpSex,
EmpAttendance.EmpDepartment,
DATEPART('m', EmpAttendance.DateOfAttendance),
EmpProfileTBL.Salary
ORDER BY
DATEPART('m', EmpAttendance.DateOfAttendance) DESC
我需要合并这两个查询。怎么做?