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 2005 Forums
 Transact-SQL (2005)
 Including Parent row in result

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2010-02-05 : 13:22:44
Hi there

User wants the rows returned to include the parent row for report.
Result wanted as such

Project Task Account Number Descr Budgeted Amount Expense
1 2 Expense Type I 10000
1 2 22 Travel 1120.00
1 2 23 Visa 20.00
1 2 Expense Type II 10000
1 2 24 Rooming 120.00
1 2 25 Office Supplies 20.00


Will I have to use ROW_NUMBER() OVER (PARTITION ) Or what would you suggest so that result returned will be as desired.

Thanks

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-05 : 13:33:12
which is parent row? what column shows parent child relationship?
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2010-02-05 : 13:44:06
Parent row is row in red. column is not shown here but the relationship is as follows. We have a list of accounts tables (sadly no identity field) then we have expenses table that shows account and expense for a project task. then we have another expense_group table (with identity field) then we have an Account_group table which groups different accounts under a expense_group. Hope this is clearer.

thanks visakh

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-05 : 13:50:38
but you need to tell us what column helps you to identify parent for a group so that we could help you with query to get parent details. also what should be your expected output?
Go to Top of Page
   

- Advertisement -