在oracle中组合多个表的多个列

时间:2020-12-06 06:06:17

I have two tables : Student_Info and Student_Academics

我有两个表:Student_Info和Student_Academics

Following are the columns in Student_Info : Id , Name , Gender , Address // Id is primary key Following are the columns in Student_Academics : SerialNo , Id , Branch , Grade // Id is foreign key

以下是Student_Info中的列:Id,Name,Gender,Address // Id是主键以下是Student_Academics中的列:SerialNo,Id,Branch,Grade // Id是外键

I want to count number of students whose gender is female and branch is CS .

我想计算性别为女性且分支是CS的学生人数。

I tried using join queries but it does not give the required information.

我尝试使用连接查询,但它没有提供所需的信息。

1 个解决方案

#1


0  

This should work,

这应该工作,

select count(1)
  from Student_Info SI, Student_Academics SA
 where si.id = sa.id
   and si.gender = 'female'
   and sa.Branch = 'CS';

#1


0  

This should work,

这应该工作,

select count(1)
  from Student_Info SI, Student_Academics SA
 where si.id = sa.id
   and si.gender = 'female'
   and sa.Branch = 'CS';