I have a simple issue where I have a table with some rows missing and need these rows to be displayed as blank in my SQL response.
Table reference below (BomNarration):
I   N   Narration
-----------------------------------------
1   1   PRODUCTION OVERSTATED ON JOBCARD
2   1   WORK CENTER NOT LOADED
3   1   REVERSE
4   1   alkjdflkdjflkajdflkjdflsjkdf
5   1   ADD PAPER
5   3   LOST03/10/19 ISGAC
6   1   04/10/19 ISGACL PAPER WILL ONLY BE AVAILBLE 999999
This shows column:
- I as the ID Number
- N as the Line Number
- Narration as the comment string
I need to use a query to return all lines (including missing Line Numbers)
For example if ID 5 is pulled up, I need to return number 1, 2 and 3.
The problem here is there is no line 2 so i need the query to fill in the missing line with a blank comment
Expected result:
I   N   Narration
-----------------------------
5   1   ADD PAPER
5   2   
5   3   LOST03/10/19 ISGAC
NOTE: that results will always start with 1 and can be up to 50.
If this is possible with CTE's it would be a great advantage as this would by part of a much larger query referencing 4 other tables to return a single dataset.
This part of the query would be used to create a string based concatenated result with indicators to be used as line breaks (example below uses the '|' symbol) per Comment line.
As mentioned above, if I can get a result like below, it would be even better.
Expected result:
I   ConcatNarration
----------------------------------------------------------------
5   ADD PAPER|{Blank Line Number here as ''}|LOST03/10/19 ISGAC
I hope this makes sense.
 
     
    