我正在寻找一种从我的 sql 表中检索数据的更好方法。
Table 1: User data
- User Id
- User Created date
Table 2: Mapping of the user with a role
- User Id
- Role
Table 3
Role definition
Table 4 (may or may not have user data based on his activities on the site)
User data
Eg.
- User Id
- Total counts of the number of visits made on the portal
我希望编写最少数量的查询(最好是 1 个)来执行以下操作
*我想打印每个角色类型中总计数最高的用户 *
输出将如下所示:
Header UserId---Rolename--Total Count
Row1 Test1 ---Staff --1293
Row2 Test2 ---Faculty --1223
Row3 Test3 ---Dean --2283928
有什么建议么?