CREATE TABLE REPORT_INFOMATION ( USERID NUMBER NOT NULL, USERNAME VARCHAR2(100 BYTE), DEGREE_F CHAR(1 BYTE), POSITION CHAR(1 BYTE) );
ALTER TABLE REPORT_INFOMATION ADD ( CONSTRAINT PK_REPORT_INFOMATION PRIMARY KEY (USERID));
可以用如下SQL获取数据: select distinct(degree_f), (select count(position) from REPORT_INFOMATION where position ='1' and degree_f=a.degree_f) position1, (select count(position) from REPORT_INFOMATION where position ='2' and degree_f=a.degree_f) position2, (select count(position) from REPORT_INFOMATION where position ='3' and degree_f=a.degree_f) position3 from REPORT_INFOMATION a