Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
spanki
Starting Member
8 Posts |
Posted - 2002-05-19 : 03:01:06
|
| I have a table with the colomn orig! orig is the origination of a phone call.I have another table with the colomn extn! which means extension number.the last 4 numbers of the orig phone number is the extension.how would i go about listing the amount of calls by extension number!?!? |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-05-19 : 03:08:40
|
| select right(phoneno,4) as Extension,count(*) as CountofCalls from phonebook pinner join extensiontable eon p.right(phoneno,4) =e.extensionHTH-------------------------------------------------------------- |
 |
|
|
spanki
Starting Member
8 Posts |
Posted - 2002-05-19 : 05:22:28
|
| if i had a colomn employee_name in the same table as extn.. would i have to compare the exn name agaisnt the employee_name to acheice a list of calls by name? |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-05-19 : 09:43:29
|
| Nopes a Group by clause on name will help you.select EmployeeName,count(1) as CountofCalls from phonebook p inner join extensiontable e on p.right(phoneno,4) =e.extension group by e.EmployeenameWill give the list of calls by Nameselect EmployeeName,Right,e.extension,count(1) as CountofCalls from phonebook p inner join extensiontable e on p.right(phoneno,4) =e.extension group by e.Employeename,e.extensionwill give you calls grouped by Name and extension(sub Grouped).i will suggest you to pick a SQL for Dummies. Read Select, Group by, Joins from BOL too.HTH-------------------------------------------------------------- |
 |
|
|
spanki
Starting Member
8 Posts |
Posted - 2002-05-19 : 10:19:12
|
| cheers! |
 |
|
|
|
|
|