cancel
Showing results for 
Search instead for 
Did you mean: 

Join on Between

Former Member
0 Kudos

Hi All,

I've got an invoice report with data coming from 2 tables dbo.Head and dbo.Positions joined on Head.InvId=Positions.InvId. I now need to add another table dbo.Images that should be joined on Head.Date between Images.DateFrom and Images.DateTo. Problem is that definition of the report is passed through tables and joins made in Links creator, not a command so I can't make such a join in the Links creator. I tried to copy and paste the sql query to command but the report loses fields. Any idea how to cope with it?

Regards,

Przemek

Accepted Solutions (1)

Accepted Solutions (1)

ido_millet
Active Contributor
0 Kudos

One option is to add the table but remove any joins to it.  Take care of the join logic by adding a record selection condition (Report, Selection Formulas, Record...).

Former Member
0 Kudos

I did it with record selection. Images table has and will have only few records so it will do. Thank you Ido.

ido_millet
Active Contributor
0 Kudos

Excellent. Thanks for closing the loop.

Answers (1)

Answers (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Przemek,

Could you elaborate on 'I tried to copy and paste the sql query to command but the report loses fields' please?

You're best bet is to use a SQL Query via the 'Add Command' option for such Joins.

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

take a look at the attached report and try to add sql command. The new table should be joined on TrN_DataOpe BETWEEN Images.DateFrom AND Images.DateTo.

Regards,

Przemek

abhilash_kumar
Active Contributor
0 Kudos

"TrN_DataOpe BETWEEN Images.DateFrom AND Images.DateTo" is the Join between these two tables.


However, you would still need to Join one of these tables to one of the existing tables in the SQL - which table and what fields would that be on?


-Abhilash

Former Member
0 Kudos

All the joins should look like below:

TraNag

     JOIN TraElem ON TrN_TrNId=TrE_TrNId

     LEFT OUTER JOIN Images ON TrN_DataOpe BETWEEN Images.DateFrom AND Images.DateTo"

abhilash_kumar
Active Contributor
0 Kudos

And what table would this field - TrN_DataOpe be in?

-Abhilash

Former Member
0 Kudos

In TraNag.

TraNag

     JOIN TraElem ON TraNag.TrN_TrNId=TraElem.TrE_TrNId

     LEFT OUTER JOIN Images ON TraNag.TrN_DataOpe BETWEEN Images.DateFrom AND Images.DateTo"

abhilash_kumar
Active Contributor
0 Kudos

Try creating a new report against the attached SQL and see if all fields appear and work as expected.

If you wish to change the existing report's datasource from tables to this command then it's not going to be an easy task. You're better off creating a new report instead.

-Abhilash

Former Member
0 Kudos

Thank you Abhilash, Ido's suggestion does the job as much as I need it.