Oracle field format Display ____oracle

Source: Internet
Author: User

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 



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.