Home > database >  The SQL query problem
The SQL query problem

Time:10-13

Problem screenshots below, there are great god teach SQL,

CodePudding user response:

(1) SELECT A.A CCOUNT, USERS=COUNT (B.T ELEPHONE)
, RENT=SUM (A.R ENT), FEE01=SUM (b. EE01), FEE02=SUM (b. EE02), FEE03=SUM (b. EE03), FEE04=SUM (b. EE04)
FROM the USER A
The JOIN at B
ON A.T ELEPHONE=B.T ELEPHONE
GROUP BY A.A CCOUNT
(2) SELECT A.A CCOUNT
FROM the USER A
The JOIN at B
ON A.T ELEPHONE=B.T ELEPHONE
GROUP BY A.A CCOUNT
HAVING a COUNT (B.T ELEPHONE) & gt; 3
(3). SELECT A.T ELEPHONE
FROM the USER A
The JOIN at B
ON A.T ELEPHONE=B.T ELEPHONE
The WHERE (b. EE01 + b. EE02 + b. EE03 + b. EE04) & gt; A.R ENT * 1.5

CodePudding user response:

With the explain command to have a look at this statement,

Look at the 2 table index,

CodePudding user response:

refer to the second floor erfudaoshu response:
with explain command to have a look at this statement,

Have a look at these two table index,
SQL will also have to write a query analysis index, didn't come out the whole optimization of SQL the
  • Related