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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select within a Select

Author  Topic 

petev
Starting Member

1 Post

Posted - 2010-09-15 : 14:24:48
Below is a statement that give me the results as follows:
--------------------
Tester | Total_Target_Cycle
tester1 | 5
tester2 | 6

I am trying to figure out how i can get total_defects column with only open defects only and percent changet between the target cycle and total defects.

------------------------------------------------------
Tester | Total_Target_Cycle | Total_Defects| % Change
------------------------------------------------------
tester1 | 5
tester2 | 6


HOW TO COMBINE THE TWO STATEMENTS BELOW. THANKS

select BG_detected_by Tester,COUNT(*)Total_Target_Cycle
From Bug
where BG_STATUS = 'Open'and BG_TARGET_RCYC IS NOT NULL
GROUP by BG_DETECTED_BY, BG_STATUS,BG_TARGET_RCYC

select bg_detected_by tester, count(*) Total
from bug
where bg_status = 'Open'
group by bg_status,bg_detected_by

GhantaBro
Posting Yak Master

215 Posts

Posted - 2010-09-15 : 17:10:49
check subquery or with CTE in google.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-16 : 12:25:26
[code]select COALESCE(q1.Tester,q2.Tester) AS Tester,
COALESCE(Total_Target_Cycle,0) AS Total_Target_Cycle,
COALESCE(Total,0) AS Total_Defects
from query1 q1
FULL JOIN query2 q2
On q1.tester= q2.tester
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -