私はcan_graduateに人を卒業するに十分なsum_credits(180)を読んでいるかどうかをチェックする方法を追加しようとしました。 Count(UnreadMandatory)= 0は、sum_credits> = 180のようなものを追加したいと思うところですが、動作させることはできません。PostgreSQL - 表示に "constraint"を追加する
これは私の最初の投稿ですので、親切にしてください。
これは私がとのトラブルを抱えている図である。 https://pastebin.com/ezUtRMGB
CREATE VIEW PathToGraduation AS
SELECT student.national_ID,
(SELECT sum(passedcourses.credit)
FROM passedcourses, has_classification
WHERE passedcourses.national_ID = student.national_ID AND has_classification.code = passedcourses.code) AS sum_credits,
(SELECT count(UnreadMandatory)
FROM UnreadMandatory
WHERE UnreadMandatory.national_ID = student.national_ID) AS remaining_courses,
(SELECT sum(passedcourses.credit)
FROM passedcourses, has_classification
WHERE passedcourses.national_ID = student.national_ID AND has_classification.code = passedcourses.code AND has_classification.type = 'Math_class') AS math_credits,
(SELECT count(passedcourses.credit)
FROM passedcourses, has_classification
WHERE passedcourses.national_ID = student.national_ID AND has_classification.code = passedcourses.code AND has_classification.type = 'Seminar_class') AS seminar_courses_taken,
(SELECT count(passedcourses.code)
FROM passedcourses, has_classification
WHERE passedcourses.national_ID = student.national_ID AND has_classification.code = passedcourses.code AND has_classification.type = 'Research_class') AS research_credits,
(SELECT 'YES' AS can_graduate
FROM UnreadMandatory
WHERE student.national_ID = UnreadMandatory.national_ID
HAVING COUNT(UnreadMandatory) = 0
UNION
(SELECT 'NO' AS can_graduate
FROM UnreadMandatory
WHERE student.national_ID = UnreadMandatory.national_ID
HAVING COUNT(UnreadMandatory) != 0))
そのつもり私の問題を解決していますかわかりません。 問題は私のcan_graduateがsum_creditsを見ることができないことです –