This statement is how to simplify? Is the largest date all of the data from the table, classification of various kinds of data,
The select 10 as the type, the count (*) from ssen where percent>=10.1 and the date (in the select date from ssen order by date DESC limit 1)
The union
The select 9 as the type, the count (*) from ssen where percent>=9 and percent<10.1 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 8 as the type, the count (*) from ssen where percent>=8 and percent<9 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 7 as the type, the count (*) from ssen where percent>=7 and percent<8 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 6 as the type, the count (*) from ssen where percent>=6 and percent<7 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 5 as the type, the count (*) from ssen where percent>=5 and percent<6 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 4 as the type, the count (*) from ssen where percent>=4 and percent<5 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 3 as the type, the count (*) from ssen where percent>=3 and percent<4 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 2 as the type, the count (*) from ssen where percent>=2 and percent<3 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 1 as the type, the count (*) from ssen where percent>=1 and percent<2 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 0 as the type, the count (*) from ssen where percent>=0 and percent<1 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 11 as the type, the count (*) from ssen where percent<=10.1 and the date (in the select date from SNBK order by date DESC limit 1)
The union
Select - 10 as the type, the count (*) from ssen where percent<=9 and percent> 10.1 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 9 as the type, the count (*) from ssen where percent<=- 8 and percent> 9 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 8 as the type, the count (*) from ssen where percent<=7 and percent> - 8 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 7 as the type, the count (*) from ssen where percent<=6 and percent> 7 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 6 as the type, the count (*) from ssen where percent<=5 and percent> - 6 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 5 as the type, the count (*) from ssen where percent<=4 and percent> 5 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 4 as the type, the count (*) from ssen where percent<=3 and percent> - 4 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 3 as the type, the count (*) from ssen where percent<=2 and percent> - 3 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select - 2 as the type, the count (*) from ssen where percent<=1 and percent> - 2 and the date (in the select date from ssen order by date DESC limit 1)
The union
Select 1 as the type, the count (*) from ssen where percent<0 and percent> 1 and the date (in the select date from ssen order by date DESC limit 1)
The results are as follows:
Type the count (*)
- 11 0
13-10
7-9
7-8
7 7
- June 28
- 5 32
- 4 60
- 3 106
165-2
160-1
0, 275
1 87
2 to 59
3 to 30
4 26
May 13
June 15
7 1
8 1
September 15
10 0
CodePudding user response:
Try a CASE the WHENCodePudding user response:
Thank you upstairs, but there is a small problem,The SELECT CASE
The WHEN percent>=10.1 THEN 10
The WHEN percent>=9 and percent<10.1 THEN 9
The WHEN percent>=8 and percent<9 THEN 8
The WHEN percent>=7 and percent<8 THEN 7
The WHEN percent>=6 and percent<7 THEN 6
The WHEN percent>=5 and percent<6 THEN 5
The WHEN percent>=4 and percent<5 THEN 4
The WHEN percent>=3 and percent<4 THEN 3
The WHEN percent>=2 and percent<3 THEN 2
The WHEN percent>=1 and percent<2 THEN 1
The WHEN percent>=0 and percent<1 THEN 0
The WHEN percent<11
=10.1 THEN -The WHEN percent<=9 and percent> 10.1 THEN - 10
The WHEN percent<=- 8 and percent> 9 THEN - 9
The WHEN percent<=7 and percent> 8 THEN - 8
The WHEN percent<=6 and percent> 7 THEN - 7
The WHEN percent<=5 and percent> - 6 THEN -
The WHEN percent<=4 and percent> 5 THEN - 5
The WHEN percent<=3 and percent> 4 THEN - 4
The WHEN percent<=2 and percent> 3 THEN - 3
The WHEN percent<=1 and percent> 2 THEN - 2
-The WHEN percent<0 and percent> 1 THEN - 1
The ELSE NULL END percent,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull