Home > database >  A simple classification of calculating the SQL statement
A simple classification of calculating the SQL statement

Time:10-08

The same mobile used by different name 3 times or more, thank you
The original table:


The end result:


Tried many times, find out
Please, help me a look

CodePudding user response:

SELECT * FROM table1 the FROM mobile IN
(SELECT mobile FROM table1 GROUP BY mobile HAVING COUNT (1) & gt; 2);

CodePudding user response:

Have done
 - 3. Select 2 mobile all records, according to mobile ascending order 
SELECT * from test where mobile in
(
- 2. 1 the result is saved as a temporary table temp_t, screening and mobile repeat 3 times or more mobile
Select mobile from
(
- 1. According to the mobile, grouping name, namely the combination of mobile and name the only
SELECT * from the test GROUP BY mobile, name
) as temp_t GROUP BY mobile HAVING count (mobile) & gt;=3
) order by mobile asc

CodePudding user response:

reference 1st floor qq_18379499 response:
SELECT * FROM table1 the FROM mobile IN
(SELECT mobile FROM table1 GROUP BY mobile HAVING COUNT (1) & gt; 2);

No oh

CodePudding user response:

 SELECT * FROM the test S 
WHERE the EXISTS
(SELECT one FROM the test
WHERE mobile=S.m obile
HAVING a COUNT (DISTINCT name) & gt; 2);

So they look more convenient

CodePudding user response:

The select statement
  • Related