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.
| Author |
Topic |
|
Trudye
Posting Yak Master
169 Posts |
Posted - 2008-02-22 : 18:18:15
|
| Does anyone have any ideas how I can accomplish this. I have a table of detail records that must be batched according to two fields (sys, prin). In other words every time the sys/prin changes in the detail record I must generate a new hdr for that group of records with like sys/prins. I have created the SELECT statements to generate the HDR’s. but I don’t know how to get them to appear in batch sequence. I also have to increas the batch number with each new batch.HDR Record(i.e. 9 0001 3641 0080) 9 = batch HDR id 0001 – batch sequence 3641 = Sys 0080 = Prin Dtl Record(i.e. 0000000001 010 23245 3641 0080) 0000000001 = Acct# 010 = trans type 23245 = amt 3641 = sys 0080 = prin This is what the output should look like 9 0001 3641 0080 0000000001 010 23245 3641 0080 0000000002 010 19265 3641 0080 0000000003 010 08845 3641 0080 9 0002 3641 0250 0000000501 010 00045 3641 0250 0000000900 010 19265 3641 0250 0000 001223 010 08845 3641 0250 My code so far: SELECT DISTINCT '9' as Batch_Type, Batch_Seq, Sys, Prin FROM Daily_Trans SELECT AcctNum, Transaction_type, Amt, Sys, Prin FROM Daily_Trans WHERE Transaction_Code = '020' ORDER By Sys, Prin |
|
|
|
|
|