SELECT
subj.SubjectID AS [ID],
subj.SubjectDescription AS [Subject],
enrol.StuSubjEnrolmentID AS [IsEnrol]
FROM [PATHWAYS].[Subjects] AS [subj]
LEFT JOIN
[STUDENT].[StuSubjEnrolment] AS [enrol]
ON subj.SubjectID = enrol.SubjectID
LEFT JOIN
[STUDENT].[Student] AS [stu]
ON enrol.StuID = stu.StuID
AND stu.StuID = @stuID
傢伙嗨,任何人都可以請指導我這個?先謝謝你。我對此很無能。SQL - 如果Else裏面的返回值?
我怎麼能寫的方式,這種說法....
當IsEnrol是不爲空,則返回0否則返回1?我想那個特定的列,只顯示1或0
嘗試使用CASE表達式 – Dejan
你希望每個IsEnrol行爲1或0,如果它是NULL /非NULL?存儲過程如何進入這個過程? – iliketocode
[如何在SQL SELECT中執行IF ... THEN]可能的重複?(http://stackoverflow.com/questions/63447/how-to-perform-an-if-then-in-an-sql - 請選擇) –