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

Time:10-25

The query to do???????????

CodePudding user response:

Question 1:
 select c1, count (*) 
The from (
The select c1 from t
Union all
Select the c2 from t
.
Union all
Select the c7 from t) total
Group by c1
The order by the count (*) desc;

Question 2:
 with recursive n (c) as (
Select 1
Union all
Select c + 1 from n where c & lt; 36
)
Select * from n
Where c not in
(
The select c1 from t
Union all
Select the c2 from t
.
Union all
Select the c7 from t)
;

CodePudding user response:

1/f,
reference Dong Xuyang TonyDong response:
question 1:
 select c1, count (*) 
The from (
The select c1 from t
Union all
Select the c2 from t
.
Union all
Select the c7 from t) total
Group by c1
The order by the count (*) desc;

Question 2:
 with recursive n (c) as (
Select 1
Union all
Select c + 1 from n where c & lt; 36
)
Select * from n
Where c not in
(
The select c1 from t
Union all
Select the c2 from t
.
Union all
Select the c7 from t)
;
brother, to explain the no...
  • Related