Home > database >  Ask: the actual number of rows returned beyond the request of the number of rows
Ask: the actual number of rows returned beyond the request of the number of rows

Time:09-20

Table create
The create table student (
Stuno number (10) not null,
Sname varchar (10) not null,
Sex char (4) the constraint sex_check check (sex='male' or sex='female'),
The age int the constraint age_check check (age> 0 and age<120),
Native_place varchar (10) not null,
Department varchar (20) not null,
Dapno number (2) not null,
Lead a varchar (20) not null,
Cscore number (3) not null,
The constraint student_pk primary key (stuno)
);

Insert into student values (20120211, 'ZhanPengFei' and 'male', 23, 'in guangdong,' computer department, 10, 'zhang, 590);
Insert into student values (20120212, 'Wang Jiawei' and 'male', 22, 'guangxi,' computer department, 10, 'zhang, 576);
Insert into student values (20120213, 'liu Yang', 'male', 21, 'zhejiang', 'computer department, 10,' zhang, 590);
Insert into student values (20120214, 'Xu Junjie' and 'male', 21, 'Shanghai', 'department of biochemistry, 20,' bill, 567);
Insert into student values (20120215, 'Lu Hongjian' and 'male', 23, 'jiangsu', 'department of biochemistry, 20,' bill, 456);
Insert into student values (20120216, 'Morgan wang', 'woman', 24, 'zhejiang', 'Chinese', 30, 'Cathy', 563);
Insert into student values (20120217, 'Jeffrey Chen' and 'male', 21, 'zhejiang', 'Chinese', 30, 'Cathy', 345);
Insert into student values (20120218, 'hui-min Lin', 'woman', 23, 'zhejiang', 'electronic information, 40,' zhao zilong, 456);
Insert into student values (20120219, 'Chen', 'woman, 22,' Shanghai ', 'electronic information, 40,' zhao zilong, 456);
Insert into student values (20120220, 'Huang Jingyi', 'woman', 23, 'jiangsu', 'electronic information, 40,' zhao zilong, 561);


(2) create a function called "FUNC_DEPT_INFO", in order to don't number of parameters, return the number of names, Numbers and the average sat scores,
(3) through func_dept_info function calls, output each department name, number and average sat scores,

The second picture of the problem is how to return a responsibility?

CodePudding user response:

An error term is a function you line 10, returned to the multiple values

CodePudding user response:

Should create a new department information table, the information such as deposit deptno and the deptname, only the deptno are stored in the student table, through the field associated with department
How from the student table grab, obvious returns multiple records, and student store dept information, may also exist the same deptno different the deptname hidden trouble
  • Related