Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 14th, 2006, 03:25 PM
gavr0s gavr0s is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 3 gavr0s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 3 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old August 15th, 2006, 10:33 AM
gavr0s gavr0s is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 3 gavr0s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 3 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old December 31st, 2012, 05:06 PM
elalerariut elalerariut is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Location: Japan
Posts: 1 elalerariut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 18 sec
Reputation Power: 0
Send a message via ICQ to elalerariut
ugg サボ

[url=http://

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Nested Select Statement


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap