Repeat the field value of an SQL query

2

I'm doing a query in SQL and with the following need in the table I have the document in two moments or status (1) when it originates and (2) when it is "linked to another process" the point is that when I generate the query only the records of moment 1 have a description and I also require it at time 2.

In my query I use a left join to bring other values that depend on the documents related to the receipts, however I understand that by the logic of the query I can not understand the logic to be able to repeat the value according to the exposed up.

Select  
T01."Transaction No_" AS "Transacción",  
T01."Entry No_" AS "Registro",  
T01."Entry Type" AS "TipoR",  
T01."Cust_ Ledger Entry No_" AS "Rcte",  
T01."Posting Date" AS "FechaR",  
T01."Document No_" AS "Docto",  
T01."Amount (LCY)" AS "Importe", 
T01."Customer No_" AS "CFacturado",  
T02."Name" AS "Nombre",  
T03."Description" AS "Descripción",  
T03."Bal_ Account No_" AS "Cta",  
T03."Bal_ Account Type" AS "TipoCta",  
T03."No_ Series" AS "Serie",  
T04."Posting Date" AS "FechaR",  
T04."Document No_" AS "Docto"  
 FROM  
 RTM1.dbo."BD$Detailed Cust_ Ledg_ Entry" "T01",  
 RTM1.dbo."BD$Customer" "T02",  
 RTM1.dbo."BD$Cust_ Ledger Entry" "T03"  
 Left Join  
 RTM1.dbo."BD$Cust_ Ledger Entry" "T04"  
 on  
 T03."Entry No_" = T04."Entry No_"  
 WHERE  
 "T01"."Customer No_" = "T02"."No_"  
 AND "T01"."Cust_ Ledger Entry No_" = "T03"."Entry No_"  
  AND T01."Posting Date"  BETWEEN date1 and date2 "  

The space of the red circle is where I want to repeat the information in common have the type of document (which does not appear here, the customer number and the document number:

    
asked by Ruben GA 09.03.2018 в 00:27
source

1 answer

0

Because of the nature of left join if you do not find T03.[Entry No_] in the field T04.[Entry No_] will show it as empty. If you are connecting this query with Excel, one option is to use Power Query for it. It's a complement that will allow you to connect Excel directly with the query and will have a whole range of tools to transform your data.

for your case, you can arrange upwards by the field [Transacción] and then fill down in the field [Descripción] to eliminate blank spaces. In the end it will only be right click > Update and you will always have your report up to date.

    
answered by 10.03.2018 в 18:44