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
 Help Needed

Author  Topic 

sachin22022
Starting Member

1 Post

Posted - 2008-07-08 : 00:33:13
Hi Gurus,

I am a bit new to sql server stuff as I have been actively involved in the business logic and presentation stuff in web development. However lately I have been assigned the task of building TFS reports and for the same I am writing a query that is needed for a report. The issue that I am facing is that I am able to make the correct sql query and it is running correctly, returning the right number of records as its supposed to return. However, the query is a set of subqueries and I want to fetch the columns that are available in the innermost query.

Select b1.[Build Type], a1.[Team Project]
-- , [Team Project].[Team Project] ->> this is not permissible
from
(SELECT [Current Work Item].*
FROM [Work Item] INNER JOIN
[Current Work Item] ON [Work Item].__ID = [Current Work Item].[Work Item]) a1
inner join
(
SELECT [Build].[__ID], Build.[Build Type]
FROM dbo.Build INNER JOIN
dbo.[Build Details] ON dbo.Build.__ID = dbo.[Build Details].Build where
Build.[Build Type]IN
(
SELECT [OSI_Build_BuildType]
FROM [Work Item] INNER JOIN
[Current Work Item] ON [Work Item].__ID = [Current Work Item].[Work Item] INNER JOIN
[Team Project] ON [Current Work Item].[Team Project] = [Team Project].__ID
WHERE ([Work Item].system_workitemtype = 'Branch') AND ([Work Item].system_state = 'Active') AND
([Team Project].[__id] IN (7) and [OSI_Build_BuildType] is not null)
)
and [Team Project] IN (7)
) b1
on a1.[Microsoft_VSTS_Build_IntegrationBuild]=b1.__ID

The issue is that I want to include the [Team Project].[Team Project] in the resultset. How can I achieve the same. Any help is really appreciated.

Thanks in advance,
Sachin

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-08 : 04:22:15
Can you provide some sample data from your tables and also output you require out of them?
Go to Top of Page
   

- Advertisement -