Build Table Statement (ORACL) (Contains records)
--Create TABLE
CREATE TABLE STUDENT
(studentid number (),
studentname VARCHAR2 (30),
studentscores Number (3)
)
INSERT into STUDENT (StudentID, Studentname, studentscores)
VALUES (1001, ' Dick ', MB);
INSERT into STUDENT (StudentID, Studentname, studentscores)
VALUES (1002, ' Dick ',);
INSERT into STUDENT (StudentID, Studentname, studentscores)
VALUES (1003, ' Dick ',);
INSERT into STUDENT (StudentID, Studentname, studentscores)
VALUES (1001, ' John ', MB);
INSERT into STUDENT (StudentID, Studentname, studentscores)
VALUES (1002, ' John ',);
INSERT into STUDENT (StudentID, Studentname, studentscores)
VALUES (1003, ' John ', 99);
Original display
Required to show
Note: Among them, the StudentID (1001, 1002, 1003) represent the language, the number and the outside respectively; Studentname is the name; Studentscores is the credit.
Answer
SELECT s.studentname as "name",
Max (DECODE (s.studentid,1001,s.studentscores,0)) as "language",
Max (DECODE (S). studentid,1002,s.studentscores,0)) as "mathematics",
MAX (DECODE (s.studentid,1003,s.studentscores,0)) as "English"
from STUDENT S
GROUP by S.studentname