A frequency calculation table SQL fields appear in the table field B

SELECT A.Id,A.Name,COUNT(B.LiveID) AS count from SetLiveHistory B RIGHT JOIN Live A ON B.LiveId=A.Id GROUP BY A.Id,A.Name ORDER BY count;

 

Additional conditions:

select A.Id,A.Name,COUNT(B.LiveID) as count from
(select * from SetLiveHistory where time >= '2020-03-1') B
right join Live A ON B.LiveId=A.Id group by A.Id,A.Name order by count;

 


https://ask.csdn.net/questions/749402

Guess you like

Origin www.cnblogs.com/wintertone/p/12602479.html