SQL语句:
- Select Top 10 UG.GroupName,(Case When IU.TNum Is Null Then 0 Else IU.TNum End) AS TNum,(Case When IU.VNum Is Null Then 0 Else IU.VNum End) AS VNum From KS_Usergroup UG Left Join (Select U.Groupid,Count(I.ID) AS TNum,Count(Case When Verific=1 Then 1 End) AS VNum From KS_Iteminfo I Inner Join KS_User U On I.Inputer=U.UserName Group By U.Groupid) IU On UG.ID=IU.GroupID Where UG.Type=1 Order By IU.TNum Desc,IU.VNum Desc,UG.ID
循环体:
- <table cellspacing="0" border="1" bordercolor="#cbdbea"> <tr bgcolor="#e8f1fa"> <td width="30" class="fontSize">排名</td> <td width="100" class="fontSize">单位名称</td> <td width="50" class="fontSize">投稿</td> <td width="50" class="fontSize">采纳</td> </tr> [loop=10] <tr> <td>{$AutoID}</td> <td>{$Field(groupname,Text,0,...,0,)}</td> <td>{$Field(tnum,Num,0,2)}</td> <td>{$Field(vnum,Num,0,2)}</td> </tr> [/loop] </table>
效果:
注:请用到SQL数据库 ACCESS不支持Case语句