1. SELECT DISTINCT
  2. b.name bank,
  3. ib.YEAR,
  4. ib.MONTH,
  5. ip.category,
  6. customer.customer_number,
  7. customer.name,
  8. customer.has_bad_address,
  9. address.line1,
  10. address.line2,
  11. address.city,
  12. state.name,
  13. address.zip,
  14. po_box.line1,
  15. po_box.line2,
  16. po_box.city,
  17. po_state.name,
  18. po_box.zip,
  19. customer.date_of_birth,
  20. northway_account.cffna,
  21. northway_account.cfinsc,
  22. customer.deceased,
  23. customer.social_security_number,
  24. customer.has_internet_banking,
  25. customer.safe_deposit_box,
  26. account.has_bill_pay,
  27. account.has_e_statement,
  28. branch.NUMBER,
  29. northway_product.code,
  30. macatawa_product.code,
  31. account.account_number,
  32. account.available_line,
  33. view_macatawa_atm_card.NUMBER,
  34. view_macatawa_debit_card.NUMBER,
  35. uc.code use_class,
  36. account.open_date,
  37. account.balance,
  38. account.affinion,
  39. northway_account.ytdsc,
  40. northway_account.ytdodf,
  41. northway_account.ytdnsf,
  42. northway_account.rtckcy,
  43. northway_account.rtckwy,
  44. northway_account.odwvey,
  45. northway_account.ytdscw,
  46. northway_account.feeytd,
  47. customer.do_not_mail,
  48. northway_account.aledq1,
  49. northway_account.aledq2,
  50. northway_account.aledq3,
  51. northway_account.aledq4,
  52. northway_account.acolq1,
  53. northway_account.acolq2,
  54. northway_account.acolq3,
  55. northway_account.acolq4,
  56. o.officer_number,
  57. northway_account.avg_bal_1,
  58. northway_account.avg_bal_2,
  59. northway_account.avg_bal_3,
  60. account.maturity_date,
  61. account.interest_rate,
  62. northway_account.asslc,
  63. northway_account.paidlc,
  64. northway_account.lnuchg,
  65. northway_account.ytdlc,
  66. northway_account.extfee,
  67. northway_account.penamt,
  68. northway_account.cdytdwaive,
  69. northway_account.cdterm,
  70. northway_account.cdtcod,
  71. account.date_of_last_statement,
  72. northway_account.statement_cycle,
  73. northway_account.cfna1,
  74. northway_account.cfna2,
  75. northway_account.cfna3,
  76. northway_account.cfna4,
  77. northway_account.cfcity,
  78. northway_account.cfstate,
  79. northway_account.cfzip,
  80. northway_account.actype,
  81. northway_account.sccode,
  82. macatawa_account.account_type_code,
  83. macatawa_account.account_type_code_description,
  84. macatawa_account.advance_code,
  85. macatawa_account.amount_last_advance,
  86. macatawa_account.amount_last_payment,
  87. macatawa_account.available_credit,
  88. macatawa_account.balance_last_statement,
  89. macatawa_account.billing_day,
  90. macatawa_account.birthday_3,
  91. macatawa_account.birthday_name_2,
  92. macatawa_account.ceiling_rate,
  93. macatawa_account.class_code,
  94. macatawa_account.classified_doubtful,
  95. macatawa_account.classified_loss,
  96. macatawa_account.classified_special,
  97. macatawa_account.classified_substandard,
  98. macatawa_account.closed_account_flag,
  99. macatawa_account.closing_balance,
  100. macatawa_account.compounding_code,
  101. macatawa_account.cost_center_full,
  102. macatawa_account.cytd_aggregate_balance,
  103. macatawa_account.cytd_amount_of_advances,
  104. macatawa_account.cytd_amount_of_payments,
  105. macatawa_account.cytd_average_balance,
  106. macatawa_account.cytd_average_principal_balance,
  107. macatawa_account.cytd_interest_paid,
  108. macatawa_account.cytd_number_items_nsf,
  109. macatawa_account.cytd_number_of_advanes,
  110. macatawa_account.cytd_number_of_payments,
  111. macatawa_account.cytd_number_times_od,
  112. macatawa_account.cytd_other_charges,
  113. macatawa_account.cytd_other_charges_waived,
  114. macatawa_account.cytd_reporting_points,
  115. macatawa_account.cytd_service_charge,
  116. macatawa_account.cytd_service_charge_waived,
  117. macatawa_account.date_closed,
  118. macatawa_account.date_last_activity,
  119. macatawa_account.date_last_advance,
  120. macatawa_account.date_last_payment,
  121. macatawa_account.date_paid_off,
  122. macatawa_account.ddl_code,
  123. macatawa_account.deposit_rate_index,
  124. macatawa_account.employee_officer_director_full_desc,
  125. macatawa_account.floor_rate,
  126. macatawa_account.handling_code,
  127. macatawa_account.how_paid_code,
  128. macatawa_account.interest_frequency,
  129. macatawa_account.ira_plan,
  130. macatawa_account.load_rate_code,
  131. macatawa_account.loan_rate_code,
  132. macatawa_account.loan_rating_code,
  133. macatawa_account.loan_rating_code_1_full_desc,
  134. macatawa_account.loan_rating_code_2_full_desc,
  135. macatawa_account.loan_rating_code_3_full_desc,
  136. macatawa_account.loan_to_value_ratio,
  137. macatawa_account.maximum_credit,
  138. macatawa_account.miscellaneous_code_full_desc,
  139. macatawa_account.months_to_maturity,
  140. macatawa_account.msa_code,
  141. macatawa_account.mtd_agg_available_balance,
  142. macatawa_account.naics_code,
  143. macatawa_account.name_2,
  144. macatawa_account.name_3,
  145. macatawa_account.name_line,
  146. macatawa_account.name_line_2,
  147. macatawa_account.name_line_3,
  148. macatawa_account.name_line_1,
  149. macatawa_account.net_payoff,
  150. macatawa_account.opened_by_responsibility_code_full,
  151. macatawa_account.original_issue_date,
  152. macatawa_account.original_maturity_date,
  153. macatawa_account.original_note_amount,
  154. macatawa_account.original_note_date,
  155. macatawa_account.original_prepaid_fees,
  156. macatawa_account.participation_placed_code,
  157. macatawa_account.participation_priority_code,
  158. macatawa_account.pay_to_account,
  159. macatawa_account.payment_code,
  160. macatawa_account.payoff_principal_balance,
  161. macatawa_account.percent_participated_code,
  162. macatawa_account.pmtd_number_deposit_type_1,
  163. macatawa_account.pmtd_number_deposit_type_2,
  164. macatawa_account.pmtd_number_deposit_type_3,
  165. macatawa_account.pmtd_number_type_1,
  166. macatawa_account.pmtd_number_type_2,
  167. macatawa_account.pmtd_number_type_6,
  168. macatawa_account.pmtd_number_type_8,
  169. macatawa_account.pmtd_number_type_9,
  170. macatawa_account.principal,
  171. macatawa_account.purpose_code,
  172. macatawa_account.purpose_code_full_desc,
  173. macatawa_account.pytd_number_of_items_nsf,
  174. macatawa_account.pytd_number_of_times_od,
  175. macatawa_account.rate_adjuster,
  176. macatawa_account.rate_over_split,
  177. macatawa_account.rate_under_split,
  178. macatawa_account.renewal_code,
  179. macatawa_account.renewal_date,
  180. macatawa_account.responsibility_code_full,
  181. macatawa_account.secured_unsecured_code,
  182. macatawa_account.short_first_name_1,
  183. macatawa_account.short_first_name_2,
  184. macatawa_account.short_first_name_3,
  185. macatawa_account.short_last_name_1,
  186. macatawa_account.short_last_name_2,
  187. macatawa_account.short_last_name_3,
  188. macatawa_account.statement_cycle,
  189. macatawa_account.statement_rate,
  190. macatawa_account.status_code,
  191. macatawa_account.tax_id_number_name_2,
  192. macatawa_account.tax_id_number_name_3,
  193. macatawa_account.teller_alert_1,
  194. macatawa_account.teller_alert_2,
  195. macatawa_account.teller_alert_3,
  196. macatawa_account.term,
  197. macatawa_account.term_code,
  198. macatawa_account.times_past_due_01_29,
  199. macatawa_account.times_past_due_01_to_29_days,
  200. macatawa_account.times_past_due_30_59,
  201. macatawa_account.times_past_due_30_to_59_days,
  202. macatawa_account.times_past_due_60_89,
  203. macatawa_account.times_past_due_60_to_89_days,
  204. macatawa_account.times_past_due_over_90,
  205. macatawa_account.times_past_due_over_90_days,
  206. macatawa_account.tin_code_name_1,
  207. macatawa_account.tin_code_name,
  208. macatawa_account.tin_code_name_2,
  209. macatawa_account.tin_code_name_3,
  210. macatawa_account.total_amount_past_due,
  211. macatawa_account.waiver_od_charge,
  212. macatawa_account.waiver_od_charge_description,
  213. macatawa_account.waiver_service_charge_code,
  214. macatawa_account.waiver_transfer_advance_fee,
  215. macatawa_account.short_first_name,
  216. macatawa_account.short_last_name          
  217.          
  218.             FROM account
  219.             JOIN customer ON account.customer_id = customer.id
  220.             JOIN officer o ON account.officer_id = o.id
  221.             JOIN account_address aa ON aa.account_id = account.id
  222.        LEFT JOIN account_po_box apb ON apb.account_id = account.id
  223.             JOIN address ON aa.address_id = address.id
  224.        LEFT JOIN original_address oa ON oa.account_id = account.id
  225.        LEFT JOIN address po_box ON apb.address_id = po_box.id
  226.             JOIN state ON state.id = address.state_id
  227.        LEFT JOIN state po_state ON po_state.id = po_box.state_id
  228.        LEFT JOIN branch ON account.branch_id = branch.id
  229.             JOIN account_import ai ON account.account_import_id = ai.id
  230.             JOIN generic_import gi ON gi.id = ai.generic_import_id
  231.             JOIN import_bundle ib ON gi.import_bundle_id = ib.id
  232.             JOIN import_profile ip ON gi.import_profile_id = ip.id
  233.             JOIN bank b ON b.id = ib.bank_id
  234.        LEFT JOIN cd_type ON account.cd_type_id = cd_type.id
  235.        LEFT JOIN account_macatawa_product amp ON amp.account_id = account.id
  236.        LEFT JOIN account_northway_product anp ON anp.account_id = account.id
  237.        LEFT JOIN macatawa_product ON macatawa_product.id = amp.macatawa_product_id
  238.        LEFT JOIN northway_product ON northway_product.id = anp.northway_product_id
  239.        LEFT JOIN product_type pt ON pt.id = macatawa_product.product_type_id
  240.        LEFT JOIN harte_hanks_service_category hhsc ON hhsc.id = macatawa_product.harte_hanks_service_category_id
  241.        LEFT JOIN core_file_type cft ON cft.id = macatawa_product.core_file_type_id
  242.        LEFT JOIN use_class uc ON account.use_class_id = uc.id
  243.        LEFT JOIN account_type at ON account.account_type_id = at.id
  244.        LEFT JOIN northway_account ON northway_account.account_id = account.id
  245.        LEFT JOIN macatawa_account ON macatawa_account.account_id = account.id
  246.        LEFT JOIN view_macatawa_debit_card ON view_macatawa_debit_card.account_id = account.id
  247.        LEFT JOIN view_macatawa_atm_card ON view_macatawa_atm_card.account_id = account.id
  248.  
  249.         WHERE 1
  250.            AND gi.active = 1
  251.            AND ib.active = 1
  252. AND ib.id = 95
  253.   LIMIT 10