38 lines
2.2 KiB
SQL
38 lines
2.2 KiB
SQL
--点赞榜 查询按照点赞数从高到低进行降序。 先去点赞表中查询到当月的点赞数据,
|
|
--再根据点赞的图片找到对应的用户,最后根据用户进行分组排序
|
|
select UserId,Totals,UserCount,(select NickName from HissAI_UserData.dbo.T_Users u where u.Id=t.UserId ) NickName,
|
|
(select UserIconUrl from HissAI_UserData.dbo.T_Users_Data u where u.UserId=t.UserId ) UserIconUrl
|
|
from (
|
|
select top 30 UserId,sum(c) Totals,count(1) UserCount from (
|
|
select DrawId,count(1) c,
|
|
(select top 1 UserId from HissAI_UserData.dbo.T_User_Gallery where DrawId=l.DrawId) UserId
|
|
from ( select DrawId,CreateTime as ExaminationDatetime,UserId from HissAI_UserData.dbo.T_User_Like li ) l
|
|
where ExaminationDatetime>='2024-02-01' and ExaminationDatetime<'2024-03-01' group by DrawId
|
|
) x where UserId!='' group by UserId order by Totals desc
|
|
) t order by Totals desc
|
|
|
|
--发布榜 先查询当月画廊有多少新增用户,然后按照用户进行分组统计
|
|
select UserId,Totals,UserCount,(select NickName from HissAI_UserData.dbo.T_Users u where u.Id=t.UserId ) NickName,(select UserIconUrl from HissAI_UserData.dbo.T_Users_Data u where u.UserId=t.UserId ) UserIconUrl from (
|
|
select top 30 UserId,count(1) Totals,count(1) UserCount from HissAI_UserData.dbo.T_User_Gallery where ExaminationDatetime>='2024-02-01' and ExaminationDatetime<'2024-03-01' group by userId
|
|
order by Totals desc
|
|
) t order by Totals desc
|
|
|
|
--被画同款榜 先查询当月所有的画同款数据,再根据上面的画同款数据找到对应的画廊用户,然后根据用户统计画同款数量,最后排序,找用户
|
|
select UserId,Totals,UserCount,(select NickName from HissAI_UserData.dbo.T_Users u where u.Id=t.UserId ) NickName,(select UserIconUrl from HissAI_UserData.dbo.T_Users_Data u where u.UserId=t.UserId ) UserIconUrl from (
|
|
select top 30 UserId,SUM(Totals) Totals,count(1) UserCount from (
|
|
select FollowDrawId,count(1) Totals from (
|
|
select FollowDrawId,CreateTime ExaminationDatetime from HissAI_Data.dbo.T_Draw_Log where FollowDrawId!='' and IsException!=1
|
|
) Draw_Log
|
|
where ExaminationDatetime>='2024-02-01' and ExaminationDatetime<'2024-03-01'
|
|
group by FollowDrawId
|
|
) drawlog inner join HissAI_UserData.dbo.T_User_Gallery g
|
|
on g.DrawId=drawlog.FollowDrawId where UserId!=0
|
|
group by UserId order by Totals desc
|
|
) t order by Totals desc
|
|
|
|
|
|
|
|
|
|
|
|
|