CR 10, SQL Server 2008
I have created a report which group by despatch_note and I have data as below (despatch table):
Despatch_Note Order_Number Order_Line_Number
100553 100364 1
100553 100364 1
100553 100364 2
100553 100364 2
100553 100364 3
There is another table linking to despatch table, named Line_Comments. The key to link both tables are Order_Number and Order_Line_Number. Data as below:
Order_Number Order_Line_Number Line_Comments_Seq Comments
100364 1 1 Test 1
100364 1 4 Test 2
100364 1 5 Test 3
The Line_Comments_Seq is not in sequential because users are allowed to delete the record after they have keyed in the comments. I would have to do a sorting by Line_Comments_Seq.
Here I need to count how many records having the same Order_Number and Order_Line_Number. In the above example, the count will be 3 for Order_Number = 100364 and Order_Line_Number = 1. For Order_Line_Number 2 and 3, the count will be 0.
I need to do this count is because I need to print the 3 comments in the report. If the count = 0, then there will be no comments to be printed. I am planning to reserve few lines to print the comments. This is the only way I can think of.
Appreciate for any help/suggestions provided. Thanks in advanced.
I have created a report which group by despatch_note and I have data as below (despatch table):
Despatch_Note Order_Number Order_Line_Number
100553 100364 1
100553 100364 1
100553 100364 2
100553 100364 2
100553 100364 3
There is another table linking to despatch table, named Line_Comments. The key to link both tables are Order_Number and Order_Line_Number. Data as below:
Order_Number Order_Line_Number Line_Comments_Seq Comments
100364 1 1 Test 1
100364 1 4 Test 2
100364 1 5 Test 3
The Line_Comments_Seq is not in sequential because users are allowed to delete the record after they have keyed in the comments. I would have to do a sorting by Line_Comments_Seq.
Here I need to count how many records having the same Order_Number and Order_Line_Number. In the above example, the count will be 3 for Order_Number = 100364 and Order_Line_Number = 1. For Order_Line_Number 2 and 3, the count will be 0.
I need to do this count is because I need to print the 3 comments in the report. If the count = 0, then there will be no comments to be printed. I am planning to reserve few lines to print the comments. This is the only way I can think of.
Appreciate for any help/suggestions provided. Thanks in advanced.