|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Nested Select Statement
Hi,
I need to write a nested Select statement but am having a little trouble. What i'm trying to achieve is a result of 4 columns: Name, Manager Ein, Issue Volume, Calls Answered. Here are the 2 statements that i believe need to be nested: SELECT p2.Forename + ' ' + p2.Surname AS name, p2.manager_ein, SUM(dbo.OfflineIssues.volume) AS volume FROM dbo.OfflineIssues INNER JOIN hierachy_info.dbo.[People Soft] p ON dbo.OfflineIssues.Ein = p.Ein INNER JOIN hierachy_info.dbo.[People Soft] p2 ON p2.Ein = p.manager_ein WHERE (p2.manager_ein = '802075268') GROUP BY p2.Forename + ' ' + p2.Surname, p2.manager_ein SELECT p2.Forename + ' ' + p2.Surname AS name, p2.manager_ein, SUM(dbo.OfflineCalls.CallsAnswered) AS CallsAnswered FROM OfflineCalls INNER JOIN hierachy_info.dbo.[People Soft] p ON dbo.OfflineCalls.Ein = p.Ein INNER JOIN hierachy_info.dbo.[People Soft] p2 ON p2.Ein = p.manager_ein WHERE (p2.manager_ein = '802075268') GROUP BY p2.Forename + ' ' + p2.Surname, p2.manager_ein Any help would be greatly appreciated. |
|
#2
|
|||
|
|||
|
got it
Seem to have fixed my own prob:
SELECT p2.Forename + ' ' + p2.Surname AS name, p2.manager_ein, SUM(dbo.OfflineIssues.volume) AS volume, (select SUM(CallsAnswered) from OfflineCalls) FROM dbo.OfflineIssues INNER JOIN hierachy_info.dbo.[People Soft] p ON dbo.OfflineIssues.Ein = p.Ein INNER JOIN hierachy_info.dbo.[People Soft] p2 ON p2.Ein = p.manager_ein WHERE (p2.manager_ein = '802075268') GROUP BY p2.Forename + ' ' + p2.Surname, p2.manager_ein a little time and thought goes a long way |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Nested Select Statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|