Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Top ten calls by user

Status
Not open for further replies.

tahoe3

IS-IT--Management
May 17, 2002
4
0
0
US
I have a telephone call table and I need to return the 10 longest calls by user last name. Fields used would be lastname and callduration. Callduration you be sorted descending.



Thanks
 
Code:
select lastname
     , callduration
  from calltable as T
 where ( select count(*) 
           from calltable  
          where callduration 
            > T.callduration ) < 10

r937.com | rudy.ca
 
select top 10 lastname, callduration
from calltable
order by callduration desc
 
Another way:
SELECT lastname, callduration
FROM calltable AS A
WHERE callduration In (SELECT TOP 10 callduration
FROM calltable WHERE lastname=A.lastname ORDER BY 1 DESC)
ORDER BY 1, 2 DESC

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top