我正在尝试将下面的查询从SQL Server转换为Oracle SQL。我不确定 关于Oracle的IFF条件。
SELECT IIF(Grade<8, NULL,Name) As Name ,Grade,Marks
FROM Grade,Students
WHERE Marks>=Min_Mark and Marks<=Max_Mark
ORDER BY Grade DESC, Name ASC;
答案 0 :(得分:2)
您可以尝试以下操作
SELECT case when Grade<8 then NULL else Name end As Name ,Grade,Marks
FROM Grade,Students
WHERE Marks>=Min_Mark and Marks<=Max_Mark
ORDER BY Grade DESC, Name ASC;
但是我更喜欢像下面这样的显式联接
SELECT case when Grade<8 then NULL else Name end As Name ,Grade,Marks
FROM Grade join Students
on Grade.Marks>=Students.Min_Mark and
Grade.Marks<=Students.Max_Mark
ORDER BY Grade DESC, Name ASC;