Home > database >  After the SQL is not a single group for help sum ratio statement again
After the SQL is not a single group for help sum ratio statement again

Time:09-30

Problem two tables
A table a.X M01, a.X M02, a.X M03, a.X M04 four fields is record data every day, every day four fields of data respectively with b table after sum total quantity ratio calculated

I.e., the result is the SUM (a.X M01)/b.X M01, SUM (a.X M02)/b.X M02, SUM (a.X M03)/b.X M03, SUM (a.X M04)/b.X M04


=========

B table b.X M01, b.X M02, b.X M03, b.X M04


Select SUM (a.X M01), SUM (a.X M02), SUM (a.X M03), SUM (a.X M04), b.X M01, b.X M02, b.X M03, b.X M04 from T_GCGL_MRZYNR a, T_GCGL_DTGC b
Where a. d. TGCID=186 and a. d. WLX=1 and a. d. TGCID=b.D TGCID

The above statement error
I don't know how to write
O great god teach

CodePudding user response:

No group by that after the sum (), the ratio to calculate what meaning, in accordance with your ideas followed by SQL group by line


Select SUM (a.X M01), SUM (a.X M02), SUM (a.X M03), SUM (a.X M04), b.X M01, b.X M02, b.X M03, b.X M04 from a, b
Where a. d. TGCID=186 and a. d. WLX=1 and a. d. TGCID=b.D TGCID
Group by b.X M01, b.X M02, b.X M03, b.X M04

CodePudding user response:

The original data looks like, what is your expected results?

CodePudding user response:

What is error message?
You this sum should be grouped
Group by DTGCID

CodePudding user response:

Behind A table in front of the SUM of the result is A single line, table B is A column, the results of the two together to form A reasonable table,

CodePudding user response:

The SUM (a.X M01)/SUM (b.X M01)

Or

The SUM (a.X M01/b.X M01)
  • Related