我需要编写一个SQL查询,显示学生平均大于55的课程名称
表格:学生,学分,课程,部门
我做了什么 :
SQL> SELECT COURSE_NAME
2 FROM COURSES
3 where
4 (select avg(grade)
5 from grades,courses
6 where
7 grades.course_id=courses.course_id)>55;
Run Code Online (Sandbox Code Playgroud)
结果很糟糕!(它显示所有课程)
表格:
create table DEPARTMENTS
(
DEPARTMENT_ID char(2),
NAME varchar2(20),
HEAD varchar2(20));
create table COURSES
(
COURSE_ID char(10),
COURSE_NAME varchar2(20),
TYPE char(6),
POINTS number(2),
DEPARTMENT_ID char(2));
create table GRADES
(
STUDENT_ID number(3),
COURSE_ID char(10),
SEMESTER varchar2(10),
TERM char(1),
GRADE number(3),
GRADE_SEM number(3));
create table STUDENTS
(
STUDENT_ID number(3),
NAME char(15),
CITY char(15));
Run Code Online (Sandbox Code Playgroud) 我有这个方法从ArrayList 中删除特定的对象P.
这是我的代码:
public void removeProduct(Product p) throws StockException{
int flag=0;
for(Product i:StockProducts)
if(p.getCode()==i.getCode()){
this.StockProducts.remove(p);
flag=1;
}
if(flag==0){
StockException e = new StockException("could not remove the Product , PRODUCT IS NOT IN THE STOCK: ", p);
throw e;
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
at java.util.ArrayList$Itr.next(Unknown Source)
at Stock.removeProduct(Stock.java:29)
at Test.main(Test.java:18)
Run Code Online (Sandbox Code Playgroud)
如果您需要有关我的代码的更多信息,请告诉我
添加方法
public void addProduct(Product p) throws StockException{
for(Product i:StockProducts)
if(p.getCode()==i.getCode()){
StockException e = new StockException("could not add the Product , CODE ALREADY …Run Code Online (Sandbox Code Playgroud)