1. Dianne Cheddar
  2. InfoMaker
  3. Wednesday, 29 November 2023 21:01 PM UTC

I am attempting to retrieve the description of the solicitation codes on a report. So, I have joined the gift_tran.solicit_cde to solicit-def.solicit_cde, however, this will only return the records with a solicitation code. How do I retrieve all records, meaning those with a solicitation code and those without. I hope this is enough information to provide feedback.

Thank you.

Dianne Cheddar Accepted Answer Pending Moderation
  1. Wednesday, 29 November 2023 23:44 PM UTC
  2. InfoMaker
  3. # 1

Awesome, thanks a lot!

Comment
There are no comments made yet.
Arnd Schmidt Accepted Answer Pending Moderation
  1. Wednesday, 29 November 2023 23:15 PM UTC
  2. InfoMaker
  3. # 2

Check out how I inserted the Join into the existing FROM Clause.

Think about using JOINs where the WHERE clause is "static".

This gives you a more visual clue about the access paths.

 

 

FROM
gift_tran
   LEFT OUTER JOIN campaign ON gift_tran.campaign_cde = campaign.campaign_cde
   LEFT OUTER JOIN solicit_def ON gift_tran.campaign_cde = solicit_def.campaign_cde,
donor_master 
   LEFT OUTER JOIN alumni_master ON donor_master.id_num = alumni_master.id_num,
name_format_basic_view,
cat_comp_2_def,
name_and_address

WHERE ( gift_tran.donor_id = name_format_basic_view.id_num ) and
( gift_tran.cat_comp_2 = cat_comp_2_def.cat_comp_2 ) and
( gift_tran.donor_id = name_format_basic_view.id_num ) and
( name_format_basic_view.id_num = name_and_address.id_num ) and
( gift_tran.donor_id = donor_master.id_num ) and
( ( gift_tran.gift_dte >= :Beg_Date ) AND
( gift_tran.gift_dte < dateadd(dd,1,:End_Date) ) AND
( gift_tran.soft_credit_yn <> 'Y' ) AND
( gift_tran.gift_class not in ('MG', 'PT', 'NC') ) )
ORDER BY name_format_basic_view.last_first_middle ASC 
Comment
There are no comments made yet.
Dianne Cheddar Accepted Answer Pending Moderation
  1. Wednesday, 29 November 2023 22:31 PM UTC
  2. InfoMaker
  3. # 3

Thanks Arnd for your prompt response. The left outer join gives the following error 'the objects gift_tran and gift_tran in the FROM clause have same exposed names. Use correlation names to distinguish them. Do you mind sharing how to accomplish the correlation names. Below is a copy of the syntax without the left outer join.

SELECT gift_tran.donor_id,
name_format_basic_view.last_first_middle,
gift_tran.giving_relation,
gift_tran.gift_tran_amt,
gift_tran.sub_class_cde,
cat_comp_2_def.description,
gift_tran.gift_dte,
name_and_address.addr_line_1,
name_and_address.addr_line_2,
name_and_address.city,
name_and_address.state,
name_and_address.zip,
name_and_address.email_address,
name_and_address.phone_num,
campaign.campaign_desc,
gift_tran.notation_1,
gift_tran.notation_2,
donor_master.first_gift_dte,
gift_tran.anon_gift_tran,
alumni_master.reunion_yr_1,
solicit_def.description
FROM gift_tran LEFT OUTER JOIN campaign ON gift_tran.campaign_cde = campaign.campaign_cde, donor_master LEFT OUTER JOIN alumni_master ON donor_master.id_num = alumni_master.id_num,
name_format_basic_view,
cat_comp_2_def,
name_and_address,
solicit_def
WHERE ( gift_tran.donor_id = name_format_basic_view.id_num ) and
( gift_tran.cat_comp_2 = cat_comp_2_def.cat_comp_2 ) and
( gift_tran.donor_id = name_format_basic_view.id_num ) and
( name_format_basic_view.id_num = name_and_address.id_num ) and
( gift_tran.donor_id = donor_master.id_num ) and
( gift_tran.solicit_cde = solicit_def.solicit_cde ) and
( ( gift_tran.gift_dte >= :Beg_Date ) AND
( gift_tran.gift_dte < dateadd(dd,1,:End_Date) ) AND
( gift_tran.soft_credit_yn <> 'Y' ) AND
( gift_tran.gift_class not in ('MG', 'PT', 'NC') ) )
ORDER BY name_format_basic_view.last_first_middle ASC

Comment
There are no comments made yet.
Arnd Schmidt Accepted Answer Pending Moderation
  1. Wednesday, 29 November 2023 22:00 PM UTC
  2. InfoMaker
  3. # 4

Hi Dianne,

not sure which is which table, but I think you need a left outer join between the 2 tables.

https://www.w3schools.com/sql/sql_join_left.asp

hth

Arnd

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.