text: --select *  from email_addr_bean_rel eabr WHERE eabr.bean_id = 'beanid' AND eabr.bean_module = 'module' and eabr.deleted=0
  --SELECT filename name FROM document_revisions INNER JOIN documents ON documents.id = document_revisions.document_id
  --SELECT bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (eabr.email_address_id = ea.id) WHERE bean_module = 'module' AND ea.email_address_caps = 'email@email.com' AND eabr.deleted=0
  --SELECT emails.id , emails.name, emails.date_sent, emails.status, emails.type, emails.flagged, emails.reply_to_status, emails_text.from_addr, emails_text.to_addrs, 'Emails' polymorphic_module FROM emails JOIN emails_text on emails.id = emails_text.email_id WHERE (type = 'type' OR status = 'status') AND assigned_user_id = '10' AND emails.deleted=0
  --SELECT count(*) c FROM folders_rel where polymorphic_module = 'Emails' and folder_id = '100' and deleted = 0
  --SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = 'name' AND pg.parent_id = '10' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC
  --SELECT meetings.id, meetings_cstm.id_c FROM meetings LEFT JOIN meetings_cstm ON meetings.id = meetings_cstm.id_c WHERE meetings.deleted = 0 AND meetings.parent_type = 'module' AND meetings.parent_id = '10'
  --select camp.name, count(*) opp_count,SUM(opp.amount) as Revenue, SUM(camp.actual_cost) as Investment, ROUND((SUM(opp.amount) - SUM(camp.actual_cost))/(SUM(camp.actual_cost)), 2)*100 as ROI from opportunities opp right join campaigns camp on camp.id = opp.campaign_id where opp.sales_stage = 'Closed Won' and camp.id='10' and opp.deleted=0 group by camp.name
  --SELECT lead_source,sum(amount_usdollar/1000) as total,count(*) as opp_count FROM opportunities WHERE opportunities.deleted=0 GROUP BY lead_source ORDER BY total DESC
  --SELECT count(*) as c FROM inbound_email WHERE deleted=0 AND is_personal='1' AND group_id='10' AND status='Active'
  --SELECT c.id AS id, 'Contacts' AS related_type, '' AS name, c.first_name AS first_name, c.last_name AS last_name,c.title AS title, c.salutation AS salutation, c.primary_address_street AS primary_address_street,c.primary_address_city AS primary_address_city, c.primary_address_state AS primary_address_state,  c.primary_address_postalcode AS primary_address_postalcode, c.primary_address_country AS primary_address_country, a.name AS account_name, ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address, c.do_not_call AS do_not_call, c.phone_fax AS phone_fax, c.phone_other AS phone_other, c.phone_home AS phone_home, c.phone_mobile AS phone_mobile, c.phone_work AS phone_work FROM prospect_lists_prospects plp INNER JOIN contacts c ON plp.related_id=c.id LEFT JOIN accounts_contacts ac ON ac.contact_id=c.id LEFT JOIN accounts a ON ac.account_id=a.id AND ac.deleted=0 LEFT JOIN email_addr_bean_rel ear ON ear.bean_id=c.id AND ear.deleted=0 LEFT JOIN email_addresses ea ON ear.email_address_id=ea.id WHERE plp.prospect_list_id = '123456' AND plp.deleted=0 AND c.deleted=0 AND (ear.deleted=0 OR ear.deleted IS NULL)
  SELECT b.id FROM emails b LEFT JOIN aod_indexevent ie ON (ie.record_id = b.id AND ie.record_module = 'module') WHERE b.deleted = 0 AND (ie.id IS NULL OR ie.date_modified < b.date_modified) ORDER BY b.date_modified ASC