例如: -
Request type table
------------------------
REQID REqName ISACTIVE
---------------------------------
1 a true
2 b true
3 c true
REquest Rights table
-------------------------
ID ReTYpeId EmpId ISActive
----------------------------------
1 1 21 true
2 2 21 true
3 1 22 true
RESult Table
-----------------------
REQID REqName ISACTIVE
---------------------------------
1 a true
2 b true
3 c false
如何查询这个。
到目前为止,我尝试过这么多 SELECT tt.TransactionTypeName,tt.TransactionTypeId,tt.IsActive FROM sTransactionType tt JOIN sTransactionRights tr
ON tr.TransTypeID=tt.TransactionTypeId
WHERE tt.Division=1 AND tt.IsActive=1. i tried with case in isactive .but not working at all.
答案 0 :(得分:1)
试试这个
SELECT REQID, REqName, ISNULL(r.ISActive, 'false') AS ISACTIVE
FROM [Request type table] t
LEFT JOIN [REquest Rights table] r ON r.ReTYpeId = t.REQID AND EmpId = 21
WHERE t.ISACTIVE = 'true'