MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 21st, 2012, 02:43 PM
kalsy12 kalsy12 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 kalsy12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 sec
Reputation Power: 0
Find All the users (manager and individuals) to top level manager

I am stuck at the point where I do'nt understand how to get deeper in table

I have a table "profiles"

Userid Name MgrID
1 A 0
2 B 1
3 C 2
4 D 3
5 E 4
6 F 4
7 G 5


I need to join this with bugs to find bug count. 1 use case was simple where I need to count bugs for Top Manager "A"

select p.login_name,
count(case when b.priority = 'P0' then b.bug_id else NULL end) AS high,
count(case when b.priority = 'P1' then b.bug_id else NULL end) AS med ,
count(case when b.priority = 'P2' then b.bug_id else NULL end) AS low ,
sum(case when b.priority in ('high' , 'med' , 'low' ) then 1 else NULL end) AS Total
from bugs b
left join profiles p
on b.assigned_to = p.userid
where p.userid in (select profiles.userid from profiles where profiles.MgrID != 0)
group by p.login_name


I am unable to think through how can i find count for let's say

"B" as C reports to B, D reports to C, E and F reports to D

so my count should be all high bugs for team B , C , D , E and F

Please help

Reply With Quote
  #2  
Old December 23rd, 2012, 11:19 PM
bobert123 bobert123 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 38 bobert123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 17 m 29 sec
Reputation Power: 2
Quote:
I am unable to think through how can i find count for let's say

"B" as C reports to B, D reports to C, E and F reports to D

so my count should be all high bugs for team B , C , D , E and F


Hi Kelsey, i think it would be very helpful for you to explain what this means a little more clearly with an example and also to give us some idea of the structure of the bugs table

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Find All the users (manager and individuals) to top level manager

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 - 2013, Jelsoft Enterprises Ltd.

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