Home > database >  Multi-table connection problem,
Multi-table connection problem,

Time:09-21

A dozen table, inside have date of these two fields: "DUIZHANGRQ" medical institution code: "YILIAOJGDM,"
Now in order to query the same day, all the data of the same type of medical institutions, how to do it, I use the full join found out there are repeated, not to heavy,
, the back of the field are some statistics, how to combine all institutions and date the same data, such as DUIZHANGRQ for 3100200310153, YILIAOJGDM for 2018/7/9
Show all the data in one line, and the corresponding data fields together, such as into the row shows and 84 of them

CodePudding user response:

The group aggregation can not?
The select yiliaojgdm duizhangrq, sum (hisnum)
From the table
Group by yiliaojgdm duizhangrq

CodePudding user response:

reference 1st floor yaiger response:
group summary is ok?
The select yiliaojgdm duizhangrq, sum (hisnum)
From the table
Group by yiliaojgdm, duizhangrq


There are ten pieces of table, I here is how to collect, should be clearly defined

CodePudding user response:

UNION ALL group summary later

CodePudding user response:

reference yaiger reply: 3/f
UNION ALL later group summary

CodePudding user response:

reference yaiger reply: 3/f
UNION ALL later group summary


More than a dozen tables, only UNION ALL?

CodePudding user response:

The UNION ALL the most convenient, other methods instead of trouble
Unless the table is not fixed, but also can add or remove

CodePudding user response:

refer to 6th floor yaiger response:
UNION ALL the most convenient, other methods instead of trouble
Unless the table is not fixed, still can add or delete

Dozen form fields in addition to the three other is different, but all displayed, with the first table fields of union is not final, please

CodePudding user response:

UNION is subject to a first table fields other tables at the time of the UNION must number field and type are consistent with the first table
If this kind of thing to do, often and table number is larger, can consider according to dimension data summary to a dimension table, then directly from the dimension table values

CodePudding user response:

This table named me too tipsy feeling is amateurs

To heavy group by field