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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Join with Ordering from relational tables

Author  Topic 

Scal
Starting Member

24 Posts

Posted - 2011-06-23 : 11:29:06
Hi;
To understand what I need, here is the table's I'm using diagram: [url]http://pascalc.nougen.com/stuffs/diagram.png[/url]

I need to get a project's properties + all it's relation, all listed based on the corresponding relational tables' OrderNumber column.

Let's say I need "Project Z", I want to get:
- Project's BaseUrl, ... where ID = @ID
- All testsuites associated to that project, listed by ProjectsToTestSuites.OrderNumber
- All testcases associated to the matching testsuites, listed by TestSuitesToTestCases.OrderNumber
- All testaction associated to the matching testcases, listed by TestCasesToTestActions.OrderNumber

So far, all my attempts are returning back results with mixed ordering. A testcase is mixed inside a testsuite it doesn't belong to and alike.
I try to avoid using cursors (loop each relation in specific order required), tried the use of UNION but couldn't get it to work either.

I have a "solution" / "workaround" using temporary table but that's probably not best either.

Any advices?
Thanks

pduffin
Yak Posting Veteran

68 Posts

Posted - 2011-06-28 : 21:31:56
Could you add an example of the expected output please.
Pete
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-06-28 : 21:46:43
it will be easier for others to help you if you can edit your question and provide required information as stated in the link below

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -