0

以下のこのクエリの何が問題になっているのか誰か教えてもらえますか?プログラミングの観点からはそれは完全に理にかなっていますが、SQLはそれを好まないようです。

SNAME、YEAR、GPA FROM STUDENT
WHERE(YEAR> = 5 AND GPA <= 3.0)AND(WHERE YEAR <= 4 AND GPA <= 2.0)
ORDER BY YEAR、GPA DESC;

このエラーが発生します:

2行目のエラーORA-00936:式がありません

4

4 に答える 4

2

問題はWHERE、クエリに2つの句があることです。

また、2つのブール式のいずれかが満たされたときに完全な式が真になるように、ORではなく演算子を使用して2つのブール式を組み合わせる必要があります。AND

SELECT SNAME, YEAR, GPA 
FROM STUDENT 
WHERE (YEAR >= 5 AND GPA <=3.0) OR (YEAR <=4 AND GPA <= 2.0) 
ORDER BY YEAR, GPA DESC ;
于 2012-10-11T03:39:02.983 に答える
1

条件の余分なWHEREキーワードを削除します。

SELECT SNAME, YEAR, GPA 
FROM STUDENT 
WHERE (YEAR >= 5 AND GPA <=3.0) Or (YEAR <=4 AND GPA <= 2.0)
ORDER BY YEAR, GPA DESC 
于 2012-10-11T03:40:24.950 に答える
0

に変更してみてください

SELECT  SNAME, 
        YEAR, 
        GPA 
FROM    STUDENT 
WHERE   (YEAR >= 5 AND GPA <=3.0) 
OR  (YEAR <=4 AND GPA <= 2.0) 
ORDER BY YEAR, GPA DESC ;

2回指定しKEYWORD WHEREました。

于 2012-10-11T03:40:17.367 に答える
0

SQLでは、条件がクエリで使用されるのは1回だけです。

    SELECT SNAME, YEAR, GPA 
    FROM STUDENT 
    WHERE (YEAR >= 5 AND GPA <=3.0) OR (YEAR <=4 AND GPA <= 2.0) 
    ORDER BY YEAR, GPA DESC ;

詳細については、構文に従ってください。

     how the rows in the result set will be sorted. This clause is optional.

   Description

    You use the basic SELECT statement shown above to retrieve the
 columns specified in the SELECT clause from the base table specified
 in the FROM clause and store them in a result set.
    The WHERE clause is used to filter the rows in the base table so that
 only those rows that match the search condition are included in the
 result set. If you omit the WHERE clause, all of the rows in the base
 table are included.
    The search condition of a WHERE clause consists of one or more Boolean 
expressions, or predicates, that result in a value of True, False, or 
Unknown. If the combination of all the expressions is True, the row
 being tested is included in the result set. Otherwise, it's not.
    If you include the ORDER BY clause, the rows in the result set are
 sorted in the specified sequence. Otherwise, the sequence of the rows
 is not guaranteed by Oracle. Note
    The syntax shown above does not include all of the clauses 
of the SELECT statement. You'll learn about the other clauses later in this book.
于 2012-10-11T03:57:04.883 に答える