我有一個TBL:自我指涉的加盟,多行
| user | crs | status |
| usr1 | crs1 | stat1 |
| user1 | crs1 | stat2 |
| user2 | crs2 | stat1 |
我如何獲得:
user | crs1.status | crs2.status?
我想:
select distinct
mstr.[person username],
abt.[module name],
abt.[Lesson completion status],
eoc.[module name],
eoc.[Lesson completion status]
from
[aht16] as mstr
right join
[aht16] as abt on (mstr.[person username] = abt.[person username]
and abt.[module name] = 'sdfsdfsdfsfd)'
and abt.[Lesson completion status] = 'completed')
right join
[aht16] as EOC on (mstr.[person username] = EOC.[person username]
and eoc.[module name] = 'sdfsdfsdfs'
and eoc.[Lesson completion status] = 'completed')
where
mstr.[course title] = 'sdf'
請用您正在使用的數據庫標記您的問題。 –