Home > database >  SQL optimize the interview..
SQL optimize the interview..

Time:12-24

How the SQL optimization, and the date condition in the end, don't want to write two conditions,
 select a.A Level, count (1) HyCount, Max (p.n um) as Vnum 
The from _tmp_work a
Left the join (select count (DISTINCT videoName) as num, ALevel from _tmp_work
Where date> And date<='2020-7-1 00:00:00'; 23:59:59='2020-7-2'
Group by alevel
) p on a.A Level=p.A Level
Where a. d. ate> 00:00:00='2020-7-1' and a. d. ate<23:59:59='2020-7-2'
Group by a.A Level


CodePudding user response:

I feel you are the zha left the join is superfluous,
The select a.A Level, count (1) HyCount, count (DISTINCT videoName) as Vnum
The from _tmp_work a
Where a. d. ate> 00:00:00='2020-7-1' and a. d. ate<23:59:59='2020-7-2'
Group by a.A Level


  • Related