雖然我知道標題並不是非常具體,但我很抱歉,我需要幫助解決與SQL有關的語法問題,因爲我不完全確定部分語法錯誤,我不能更具體。SQL語法問題 - Group By - Oracle
我正在使用Oracle SQL Developer,如果有幫助的話。
SELECT DISTINCT pet.PET_NAME,
CASE
WHEN dog.PET_PET_NUMBER = pet.PET_NUMBER THEN 'Dog'
WHEN cat.PET_PET_NUMBER = pet.PET_NUMBER THEN 'Cat'
ELSE ''
END AS "Pet Type",
SUM(res.RESERVATION_START_DATE - res.RESERVATION_END_DATE) AS "Days Stayed"
FROM HVK_PET pet, HVK_DOG dog, HVK_CAT cat, HVK_RESERVATION res, HVK_PET_RESERVATION petRes
WHERE (pet.PET_NUMBER = dog.PET_PET_NUMBER
OR pet.PET_NUMBER = cat.PET_PET_NUMBER)
AND res.RESERVATION_NUMBER = petRes.RES_RESERVATION_NUMBER
AND petRes.PET_PET_NUMBER = pet.PET_NUMBER
GROUP BY pet.PET_NAME, dog.pet_pet_number, cat.pet_pet_number;
是我的完整代碼,前7行強調黃色與建議通過語句添加情況下,我的團隊。我不是SQL最偉大的人,所以如果明顯的話,不要猶豫,給我打電話吧。