0

重複を削除するにはどうすればよいですか? 10 行で、すべての学生 ID (1x) を表示する必要があります。私はこの2つの差分方法を試しました。(以下を参照) (共通フィールドは class_id です)

SQL> select distinct(student_id),event.class_id, event.event_id, event.event_name
  2  from student_class
  3  inner join event on event.class_id = student_class.class_id
  4  where student_class.class_id = '10'
  5  order by student_id desc;

STUDENT_ID   CLASS_ID   EVENT_ID EVENT_NAME
---------- ---------- ---------- --------------------------------------------------
        20         10          5 PICKUP SOCCER GAME
        20         10          2 Flag FOOtball Game
        18         10          2 Flag FOOtball Game
        18         10          5 PICKUP SOCCER GAME
        16         10          2 Flag FOOtball Game
        16         10          5 PICKUP SOCCER GAME
        12         10          5 PICKUP SOCCER GAME
        12         10          2 Flag FOOtball Game
         9         10          5 PICKUP SOCCER GAME
         9         10          2 Flag FOOtball Game
         8         10          2 Flag FOOtball Game
         8         10          5 PICKUP SOCCER GAME
         6         10          2 Flag FOOtball Game
         6         10          5 PICKUP SOCCER GAME
         4         10          5 PICKUP SOCCER GAME
         4         10          2 Flag FOOtball Game
         3         10          2 Flag FOOtball Game
         3         10          5 PICKUP SOCCER GAME
         2         10          5 PICKUP SOCCER GAME
         2         10          2 Flag FOOtball Game

SQL> select distinct(student_id), student_class.class_id,
     event.event_id, event.event_date_time
     from student_class
     inner join event on event.class_id = student_class.class_id
     order by student_id desc;

STUDENT_ID   CLASS_ID   EVENT_ID EVENT_DAT
---------- ---------- ---------- ---------
        22          9          1 09-NOV-99
        21          2          6 20-NOV-99
        21          9          1 09-NOV-99
        20          9          1 09-NOV-99
        20         10          2 19-JAN-99
        20         10          5 09-JUL-99
        18          9          1 09-NOV-99
        18         10          2 19-JAN-99
        18         10          5 09-JUL-99
        17          9          1 09-NOV-99
        16          2          6 20-NOV-99
        16          9          1 09-NOV-99
        16         10          2 19-JAN-99
        16         10          5 09-JUL-99
        15          9          1 09-NOV-99
        14          9          1 09-NOV-99
        13          9          1 09-NOV-99
        12          2          6 20-NOV-99
        12          9          1 09-NOV-99
        12         10          2 19-JAN-99
        12         10          5 09-JUL-99
        11          2          6 20-NOV-99
        11          9          1 09-NOV-99
         9         10          2 19-JAN-99
         9         10          5 09-JUL-99
         8          2          6 20-NOV-99
         8         10          2 19-JAN-99
         8         10          5 09-JUL-99
         7          2          6 20-NOV-99
         6         10          2 19-JAN-99
         6         10          5 09-JUL-99
         4         10          2 19-JAN-99
         4         10          5 09-JUL-99
         3         10          2 19-JAN-99
         3         10          5 09-JUL-99
         2          2          6 20-NOV-99
         2          9          1 09-NOV-99
         2         10          2 19-JAN-99
         2         10          5 09-JUL-99
4

1 に答える 1