HI,
I am trying to get the top 20 users from my database and order it by the name. All help is greatly appreciated.
Z
Select Top 20 FullName, Counter
(
SELECT count(tixq.tixid) as counter, UserProfile.FName + ' ' + UserProfile.LName AS FullName
FROM TixQ, UserProfile
WHERE UserProfile.UID=TixQ.Create_For
GROUP BY UserProfile.FName + ' ' + UserProfile.LName
UNION
SELECT Count(dbo.TixArchive.TixID) as counter, dbo.UserProfile.FName + ' ' + dbo.UserProfile.LName As FullName
FROM dbo.TixArchive, dbo.UserProfile
WHERE dbo.TixArchive.Create_For=dbo.UserProfile.UID
GROUP BY dbo.UserProfile.FName + ' ' + dbo.UserProfile.LName
)
ORDER BY Counter desc
I am trying to get the top 20 users from my database and order it by the name. All help is greatly appreciated.
Z
Select Top 20 FullName, Counter
(
SELECT count(tixq.tixid) as counter, UserProfile.FName + ' ' + UserProfile.LName AS FullName
FROM TixQ, UserProfile
WHERE UserProfile.UID=TixQ.Create_For
GROUP BY UserProfile.FName + ' ' + UserProfile.LName
UNION
SELECT Count(dbo.TixArchive.TixID) as counter, dbo.UserProfile.FName + ' ' + dbo.UserProfile.LName As FullName
FROM dbo.TixArchive, dbo.UserProfile
WHERE dbo.TixArchive.Create_For=dbo.UserProfile.UID
GROUP BY dbo.UserProfile.FName + ' ' + dbo.UserProfile.LName
)
ORDER BY Counter desc