Home > database >  Script, and two tables associated grouping query!
Script, and two tables associated grouping query!

Time:10-08

Demand is that the table A table, table B for the disposal of table, two things are connected, now requires access to table A department, department number, list A total number, list A number of per capita, the total number of table B, table B, the number of per capita

CodePudding user response:

Table structure post, to create table text, again collect rules and and expected results,

Or use excel to draw it

CodePudding user response:

CodePudding user response:

The select a.f DeptID sector, A table
Count (distinct a.f Name) A table department number,
Count (1) the total number of A table,
Count (distinct a.f Name)/count (1) A table per capita number,
Count (b. Name) B table total number,
Count (b. Name)/count (distinct b. Name) B table per capita number
The from Question_A a, Handle_B b
Where id=a.f b. id (+)
Group by a.f DeptID;

Default considering no wish, if you have the nuptial need to change the name fName to only personnel identification, such as personnel id or something like that