I use SAP Crystal Reports and Microsoft SQL Server Management Studio.
I have a select1 which retrieve all the jobs, sales
I have another select2 which retrieve only the jobs which have invoices to customs; for taking the invoices to customs, I have to link other tables to the original link; I use a UNION because I have to link purchases invoices and sales invoices.
Select1:
[pre]
Job Sales
J1 100
J2 150
J3 250
J4 300
J5 200
[/pre]
Select2:
[pre]
Job Sales/Purchases Customs
J2 150 50
J3 250 80
[/pre]
I have to get the result
[pre]
Job Sales/Purchases Customs
J1 100
J2 150 50
J3 250 80
J4 300
J5 200
[/pre]
I have no idea how to write a script/stored procedure to accomplish this.
Can you help?