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)
 second post --

Author  Topic 

dpais
Yak Posting Veteran

60 Posts

Posted - 2010-06-09 : 10:15:48
[code]
parent Child grp output_needed
part1 Comp01 a 10 - output increments by 10 and does not increment where grp is the same.
part1 Comp02 a 10
part1 Comp03 NULL 20
part1 Comp04 NULL 30
part1 Comp05 b 40
part1 Comp06 b 40
part1 Comp07 NULL 50
part1 Comp08 NULL 60
part2 Comp09 NULL 10 - output resets when part2 changes.
part2 Comp10 c 20
part2 Comp11 c 20
part2 Comp12 c 20
part2 Comp13 NULL 30
part2 Comp14 NULL 40
part2 Comp15 d 50
part2 Comp16 d 50
part2 Comp17 NULL 60
part2 Comp18 NULL 70[/code]
i would like the output to be genereated by sql. thank you.

DDL is
select 'part1' as parent,
'Comp01' as child, 'a' as grpinto #temp1
union
select 'part1', 'Comp02', 'a'
union
select 'part1', 'Comp03', NULL
union
select 'part1', 'Comp04', NULL
union
select 'part1', 'Comp05', 'b'
union
select 'part1', 'Comp06', 'b'
union
select 'part1', 'Comp07', NULL
union
select 'part1', 'Comp08', NULL
union
select 'part2', 'Comp09', NULL
union
select 'part2', 'Comp10', 'c'
union
select 'part2', 'Comp11', 'c'
union
select 'part2', 'Comp12', 'c'
union
select 'part2', 'Comp13', NULL
union
select 'part2', 'Comp14', NULL
union
select 'part2', 'Comp15', 'd'
union
select 'part2', 'Comp16', 'd'
union
select 'part2', 'Comp17', NULL
union
select 'part2', 'Comp18', NULL

I need the output column to be generated by SQL query. THis is Bill of material data - the output column are reference numbers on the Bill. the grp column denotes if the compnentns are alternates ... same grp's are alternate components.

Sachin.Nand

2937 Posts

Posted - 2010-06-09 : 10:42:03
Isn't this the same requirement as posted here?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=143974


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

dpais
Yak Posting Veteran

60 Posts

Posted - 2010-06-09 : 10:47:17
sorry Idera -

Maybe I should have not done that - i did not receive any response for this post previously. what is the right way of asking for help again on a previously incomplete post ?

thanks.

quote:
Originally posted by Idera

Isn't this the same requirement as posted here?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=143974


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH

Go to Top of Page
   

- Advertisement -